I need to work out the percentage in SSRS for the below data - sum the "Qty" of products where the Status = "Live" and then divide the it by the total "Qty" for all products:
Is it possible to this in SSRS expression or do I need to this in the sql query?
Weeknum___Status_____Qty
34__________Toxic______ 99
34__________ EOL______ 1819
34__________Live_______3440
34__________BER_______361
34__________Live______1
34__________Live______386
34__________BER_______39
34__________EOL______498
Fisrt you will have to create a metrix that filter the status maybe like this
=Fields!Status.Value
Then in another colum you will have to put this
=FormatPercent(sum(Fields!Qty.Value)/(Sum(Fields!Qty.Value, "YOUR DATASET"),1)
And you will get the percentages over the total of the Qty
Related
I have two tables . I have created a table visual in power BI where I am combining the two values eg below :
Table 1 :
Site Name
Type
Area(m2)
A
Hospital
50
A
Education
100
B
Tech Lab
20
B
Office
70
B
Education
90
Table 2 :
Type
Usage (hr/m2)
Type
Hospital
100
Low
Education
500
Low
Tech Lab
50
Low
Office
200
Low
This visual also has a slicer:
Usage Type
Low
Medium
High
The slicer currently chosen is lets say "Low"
On my PowerBI visual ( a table) I am merging this two tables by "Type" to give me
Site Name
Type
Area
Usage(hr/m2)
A
Hospital
50
100
A
Education
100
500
B
Tech Lab
20
50
B
Office
70
200
B
Education
90
500
The end goal is to find the usage by site. In my head the equation should be :
For A :
TotalUsage[A]=Area[Hospital]*Usage[Hospital]+Area[Education]*Usage[Education] (50x100+100x500=55000)
TotalArea[A]=Area[Hospital]+Area[Education]=150
Usage[A]=TotalUsage[A]/TotalArea[A]=55000/150~366 hr/m2
How can I achieve this ?
I first created the visual as shown above(third table)
I did quick measures for total usage for each row. The displayed that on the third table.
However when I try to measure again , this type only grouped by Site, instead of following the above equation it sums the usage rows first (so 100+500=600), then sums the area ( 50+100=150) and then calculates the usage for site A giving 600/150 ( which is wrong! )
Use these measures:
Area Usage =
SUMX(
'Table 1',
'Table 1'[Area(m2)] * LOOKUPVALUE(
'Table 2'[Usage (hr/m2)],
'Table 2'[Type], SELECTEDVALUE('Table 1'[Type]),
'Table 2'[Usage Type], SELECTEDVALUE('Table 2'[Usage Type])
)
)
Total Usage =
SUMX(
VALUES('Table 1'[Type]),
[Area Usage]
)
Total Area = SUM('Table 1'[Area(m2)])
Usage = DIVIDE([Total Usage], [Total Area]))
and put everything together in a table
I have 2 columns, Status and Date. The "Status" column contains three values ('Past Due', 'Soon Due', 'Calibrated').
I would like to display the most recent month name calculated for each of these status categories separately. Specifically, I would like to create a table visual where we have 3 different columns with the names "Past Due", "Soon Due", and "Calibrated". These columns display the most recent month name for dates corresponding to each status category, as outlined in the screenshots below.
Sample Input:
Desired Output:
FORMAT([DateField], "MMM") is the key DAX function here.
I've outlined the 3 measures below that should give you the result you want. Replace "Table1" with your table name.
Past Due
Past Due = CALCULATE(FORMAT(MAX(Table1[Date]), "MMM"), Table1[Status] = "Past Due")
Soon Due
Soon Due = CALCULATE(FORMAT(MAX(Table1[Date]), "MMM"), Table1[Status] = "Soon Due")
Calibrated
Calibrated = CALCULATE(FORMAT(MAX(Table1[Date]), "MMM"), Table1[Status] = "Calibrated")
Measures in Table
This is how my report looks like now :
I'd like the Quantity summed up for each Product , similar to how we do it in a SQL query :
select product_id ,sum(quantity) from my_table group by product_id;
This is the desired output :
product
quantity
Aluminuim
204
Bois
216
Dynamo Bicyclette
36
Guidon Bicyclette
12
Necklace string
5,530
Another option is to simply insert a CrossTab. Use the Product as the row element and Quantity as the metric to sum.
How do i use script editor in crystal report to subtract two fields in the footer
For Ex:
i have one table called "PAYMENT" and it has two fields
1> "order amount" and
2> PAYMENTAMOUNT
ORDERID PAYMENTID PAYMENTAMOUNT ORDERAMOUNT
ABC 1 100 500
ABC 2 200 500
in crystal report, i have added one field which describes the code as
DUE = ORDERAMOUNT - PAYMENTAMOUNT
for the above code, it brings the value = 400 & 300 for each record
i need add one field which shows the sum(ORDERAMOUNT) and sum(PAYMENTAMOUNT) and the final result is 500 - 300 = 200
please help
I'vre created a cross tab report with 2 calculated Member to be able to have the difference between 2 column and the percentage of this difference in CR 2011. What I want to achieve is to create a new column that will display a test depending on the difference value.
Here is a example:
Col1 Col2 Difference Percentage Action
200 0 -200 100 DROPPED
100 100 0 0
0 300 300 100 ADDED
How can create this action column. Calculated member only want some amount value so I cannot output a text in the formula.
Thanks in advance for your help
I finally found the solution.
I can use the Display string formula in the Format Field properties (Common Tab). Here I just check the column and return the string I want otherwise I just format the number.
IF GetColumnGroupIndexOf(CurrentColumnIndex) = 1
AND CurrentColumnIndex =4 THEN
IF GridValueAt(CurrentRowIndex, CurrentColumnIndex,CurrentSummaryIndex) =2 THEN "DROPPED"
ELSE "ADDED"
ELSE
ToText( GridValueAt(CurrentRowIndex, CurrentColumnIndex,CurrentSummaryIndex),2,",")