rdl report Filter sums - filter

How can i write the expression in rdl report for the following :
Sum(Fields!Amount.Value) where AccountType='Income' - SUM(Fields!Amount.Value) where AccountType='Cost of Goods Sold')
Am Using only 1 dataset with the following columns AccountType AccountName Amount

I don't know if there is any other way but this is the only way I found .
create 2 variables in the rdl report .
e.g
1st variable IncomeTotal I set the expression to
=SUM(iif(Fields!AccountType.Value="Income",CDbl(Fields!Amount.Value),CDbl(0.00)),"YourDatasetName")
2nd variable CostOfGoodsSoldTotal I set the expression to
=SUM(iif(Fields!AccountType.Value="Cost of Goods Sold",CDbl(Fields!Amount.Value),CDbl(0.00)),"YourDatasetName")
And then I subtract the 2 variables where appropriate with the following expression
=Variables!IncomeTotal.Value - Variables!CostOfGoodsSoldTotal.Value

Related

SPSS Syntax Concatenate Case Values From Single Column

I am trying to build a string of values to be inserted into an SQL IN list. For example -
SELECT * FROM TABLE WHERE field IN ('AAA', 'BBB', 'CCC', 'DDD')
The list that I want needs to be constructed from values within a single column of my dataset but I'm struggling to find a way to concatenate those values.
My first thought was to use CASESTOVARS to put each of the values into columns prior to concat. This is simple but the number of cases is variable.
Is there a way to concat all fields without specifying?
Or is there a better way to go about this?
Unfortunately Python is not an option for me in this instance.
A simple sample dataset would be -
CasestoConcat
AAA
BBB
CCC
DDD
You can use the lag function for this.
First creating a bit of sample data to demonstrate on:
data list free/grp (F1) txt (a5).
begin data
1 "aaa" 1 "bb" 1 "cccc" 2 "d" 2 "ee" 2 "fff" 2 "ggggg" 3 "hh" 3 "iii"
end data.
Now the following code makes sure that rows that belong together are consecutive. You can also sort by any other relevant variable to keep the combined text in a specific order.
sort cases by grp.
string merged (A1000).
compute merged=txt.
if $casenum>1 and grp=lag(grp) merged=concat(rtrim(merged), " ", rtrim(lag(merged))).
exe.
At this point if you want to just keep the line that has all the concatenated texts, you can use this:
add files /file=* /by grp /last=lst.
select if lst=1.
exe.

From the regular expression extractor using -1 for getting all matches, and from that how to choose the last one as a match in jmeter

Whatever may to the total number of matching outcomes
If your variable is a use __V for getting last occurrence using
${__V(a_${a_matchNr})}
or __evalVar
${__evalVar(a_${a_matchNr})}
a_matchNr return last number
refName_matchNr - the number of matches found; could be 0
As per Regular Expression Extractor documentation:
If the match number is set to a negative number, then all the possible matches in the sampler data are processed. The variables are set as follows:
refName_matchNr - the number of matches found; could be 0
refName_n, where n = 1, 2, 3 etc. - the strings as generated by the template
refName_n_gm, where m=0, 1, 2 - the groups for match n
refName - always set to the default value
refName_gn - not set
So the total number of matches is being stored in ${refName_matchNr} JMeter Variable
If you want to get the last match dynamically you can use __V() function like:
${__V(refName_${refName_matchNr})}
Replace refName with your own JMeter Variable reference name
More information: Here’s What to Do to Combine Multiple JMeter Variables

SSRS [Sort Alphanumerically]: How to sort a specific column in a report to be [A-Z] & [ASC]

I have a field set that contains bill numbers and I want to sort them first alphabetically then numerically.
For instance I have a column "Bills" that has the following sequence of bills.
- HB200
- SB60
- HB67
Desired outcome is below
- HB67
- HB200
- SB60
How can I use sorting in SSRS Group Properties to have the field sort from [A-Z] & [1 - 1000....]
This should be doable by adding just 2 separate Sort options in the group properties. To test this, I created a simple dataset using your examples.
CREATE TABLE #temp (Bills VARCHAR(20))
INSERT INTO #temp(Bills)
VALUES ('HB200'),('SB60'),('HB67')
SELECT * FROM #temp
Next, I added a matrix with a single row and a single column for my Bills field with a row group.
In the group properties, my sorting options are set up like this:
So to get this working, my theory was that you needed to isolate the numeric characters from the non-numeric characters and use each in their own sort option. To do this, I used the relatively unknown Regex Replace function in SSRS.
This expression gets only the non-numeric characters and is used in the top sorting option:
=System.Text.RegularExpressions.Regex.Replace(Fields!Bills.Value, "[0-9]", "")
While this expression isolates the numeric characters:
=System.Text.RegularExpressions.Regex.Replace(Fields!Bills.Value, "[^0-9]", "")
With these sorting options, my results match what you expect to happen.
In the sort expression for your tablix/table which is displaying the dataset, set the sort to something like:
=IIF(Fields!Bills.Value = "HB67", 1, IIF(Fields!Bills.Value = "HB200", 2, IIF(Fields!Bills.Value = "SB600", 3, 4)))
Then when you sort A-Z, it'll sort by the number given to it in the sort expression.
This is only a solution if you don't have hundreds of values, as this can become quite tedious to create if there's hundreds of possible conditions.

Qlikview sorting date dimension formatted as text

Can someone help me sort a date dimension in a QlikView pivot? The dimension is set as follows:
Week(DateField) & chr(13) & '' & Weekstart(DateField,0,-1)
An example of value:
"43
10/19/2014"
Another example:
"1
12/28/2014"
chr(13) returns a new line so that the week number and the day with which the week starts are placed on two different rows.
I have tried putting this expression in a listbox to play with it and to try different variants for sorting. Below are my attempts:
Sort by expression: =DateField
Sort by expression: =LEFT(DAY(DateField) + NUM(MONTH(DateField))*100 + YEAR(DateField)*10000,100)
Sort by expression: =LEFT(DateField,2) (not ok anyway as it would not work if multiple years were loaded)
etc
but nothing seems to work
Any help is much appreciated.
Like you said, the issue is that when you create that concatenation, it becomes a string and it's sorted as such.
Luckly, QlikView has the Dual function that can help you in this case, defining the dimension as a calculated dimension with the following expression :
=Dual(Week(DateField) & chr(13) & '' & Weekstart(DateField,0,-1), Weekstart(DateField,0,-1))
The syntax of Dual is Dual(Text, Numeric Value), meaning that it will create an object that will be represented by the value Text but sorted by the Numeric Value.
Check QlikView help page for this function for further information.
This should work:
=Weekstart(DataField,0,-1)

Concatenating string from SSIS for loop task

I have an SSIS package which loops over an array of dates. On each iteration I would like to append the current date to a string to get a full string of all the dates iterated.
What I did was to make an expression where: dateconcatvariable + ", " +currentdatevariable
However, dateconcatvariable is resetting on every iteration of the for loop and so in the end I end up with the last date iterated over instead of all the dates.
the variable is a package level variable.
Any ideas on how to get a concatenation to happen on SSIS?
Thanks!
1. Create a string variable #User::var
2. Use an Expression component and set the expression to #User::var = #User::var + (WSTR, 15)#User::yourdatevar
This should give you the general idea.

Resources