Divide Operation in SSRS - ssrs-2012

I'm working on a ssrs report, they want to see below result
[Sample Output][1]
that is the final row in the report and I want to get % value by dividing 558 with 388 in above pic.
This is what I'm designed in ssrs
[Report Design][2]
highlighted one contains below formula:
=( Sum(Fields!Male.Value + Fields!Female.Value ) / (Sum(Fields!Male.Value, "GradeCode" ) + Sum(Fields!Female.Value, "GradeCode" ) ) )
but I'm getting 100% instead of 70%.
Below are the columns I have GradeCode, Male count, female count, race.
Can someone please suggest me the correct formula?
this is the expected result [enter image description here][3]
This is my design [enter image description here][4]
This is my result [enter image description here][5]
I highlighted the last row in that I should get the result of 18/582 instead it is giving 100% (in the pic I just displayed value in % and the denominator is not present)
[1]: https://i.stack.imgur.com/jB9Lz.png
[2]: https://i.stack.imgur.com/iMc6f.png

Try to use DataSet Name into group scope.
e.g
=Sum((Fields!Male.Value + Fields!Female.Value), "Federal_Race_Group") / (Sum(Fields!Male.Value,"DataSetName" ) + Sum(Fields!Female.Value,"DataSetName" ) )
Check my report preview. I have used sample dataset.

Related

I need to perform subtraction and a filter in the same column that I create in Power BI

enter image description here
I need to create a column which subtracts [Retailer_yes_amount] and [classification_base_amount] and at the same time filter out "Not Eligible" category in [Classification] column. [Classification] column has 5 categories - Platinum, Gold, Silver, Bronze and Not eligible.
I was thinking like this New_column = calculate(([Retailer_yes_amount]-[classification_base_amount]),filter('table_name',[classification] <> "Not Eligible")) but it threw an error.
Kindly suggest
If you want to have this evaluated for every row as a new column you have to enter the following expression as a Calculated Column
New_column =
IF(
table_name[Classification] <> "Not Eligible",
[Retailer_yes_amount] - [classification_base_amount]
)
If you want to use a measure you have to specify an aggregation.

HOW TO REFERENCE A MEASURE IN A FILTER (DAX)

I have created a measure
Report_Day = MAX(DATE_LT[Date])-2
I want to create measures where they reference this measure so i can just change -2 to -1 and the rest of measures work depending on the reporting date.
when i use this measure:
Day_outlet_Txns = CALCULATE(
[outlet_Dep_Txns],
FILTER(ALL(DATE_LT),[Report_Day])
)
i get a value equal to tatal transactions in a table yet i want for transactions of that report day.
When i try something else
Day_outlet_Txns = CALCULATE(
[Issuer_Dep_Txns],
FILTER(ALL(DATE_LT), DATE_LT=[Report_Day])
)
i get an error: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
enter image description here

Total sum based on Expression Detail Items (SUM IF Line Items)

I have a table showing Turnover.
I used the same column but did a SUM IIF on the detail lined as follows:
=SUM(IIF(Fields!ID_Country.Value = 17,Fields!Turnover.Value,0))
and
=SUM(IIF(Fields!ID_Country.Value = 23,Fields!Turnover.Value,0))
17 = Great Britain
23 = Ireland
I then want to do a TOTAL per column based on my above detail rows. I just cannot find the right way to do it.
I Tried:
SUM(=SUM(IIF(Fields!ID_Country.Value = 17,Fields!Turnover.Value,0)))
But this does not work.
Please help as I am really stuck.
Thank you!
Because Turnover for GB is in Pounds and for Ireland they are in Euros, I want to split my columns and then do a final SUM for GB and Ireland.
I expect to see the grant total for per column for GB and Ireland summing my detail rows which have the expression calculation. (SUMIIF)
Table: Circled in RED is where I expect to see my TOTAL
enter image description here
Data Structure:
enter image description here

How to find the maximum value from a column satisfying two or more IF conditions in DAX

I am a newbie to Power BI and DAX.
I have a dataset as attached. I need to find the maximum value for each person for each week. I have written the formula in Excel.
=MAX(IF(A$2:A$32=A2,IF(D$2:D$32=D2,IF(B$2:B$32=1,C$2:C$32))))
How can I convert it to DAX or write the same formula in Power BI? I tried the DAX Code as below, But it did not work(ALLEXCEPT Function expects table).
Weekly Maximum =
CALCULATE ( MAX ( PT[Value] ), ALLEXCEPT ( PT, PT[person], PT[Week],
PT[category] ==1 ) )
Once I calculate this, then I need to calculate the Expected value for each week, that has the maximum value of the previous week * 2.85, as shown in the screenshot. How can I put the previous week's maximum value for this week?
Any corrections/solutions, please?
TIA
The Max Value for Category 1 can be written like this:
= CALCULATE(MAX(PT[Value]),
ALLEXCEPT(PT, PT[Person], PT[Week]),
PT[Category] = 1)
(The Category filter doesn't go inside ALLEXCEPT().)
For your Expected Value column, you can do something similar:
= CALCULATE(2.85 * MAX(PT[Value]),
ALLEXCEPT(PT, PT[Person]),
PT[Category] = 1,
PT[Week] = EARLIER(PT[Week]) - 1)
(The EARLIER function gives you the value for the row you are in. The name refers to the earlier row context.)

Show Different category name in tooltip in spotfire bar chart

We have a requirement for showing ID in category axis and description of same ID in tooltip.
I have multiple columns in my data like value 1 ,value2,value 3 etc. value 1, value 2 are columns.
I am putting this on value axis as an expression like Sum([value 1]) as [AC 6076 ], Sum([Value 2]) as [AC 6078 ], etc. that is this will hardcoded as IDs in category axis
So my category axis is column names. that is <[Axis.Default.Names]> .
please see the attached picture. It's the description against a column not a row.
It would be an expression in tooltip which may be something like
First(Case when '${Axis.Y.DisplayName}'='AC 6076' then "description 1" when '${Axis.Y.DisplayName}'='AC 6078 ' then "description 2" else " Description 3" end )
This expression is not showing correct value. it wil always show "Descrition 3"
i want to show this IDs(column names in category axis) and a description for each of these column names in tooltip. please have a look at the picture attached.
Atatched picture
Thanks
First(CASE
WHEN '${Axis.Y.DisplayName}'='AC 6076' THEN "description 1"
WHEN '${Axis.Y.DisplayName}'='AC 6078 ' THEN "description 2"
ELSE " Description 3"
END)
this always evaluates to your ELSE condition because ${Axis.Y.DisplayName} will always be the full display name for the axis, not the individual columns (i.e., "AC 6076, AC 6078").
you will need to add your description text to your data somehow. this is a little convoluted and will require some tweaking on your end, but the principle is the same.
this is assuming your table is something like this:
key val1 val2
a 1 4
b 2 5
c 3 6
from the menu, select File..Add Data Tables...
click Add then select the data table powering your visualization from the From Current Analysis heading
expand the Transformations pane at the bottom of this dialog
choose a Pivot transform and click **Add...*
leave everything default except for Transfer columns..., where you should add only the columns you wish to sum (e.g., [value 1] and [value 2])
OPTIONALLY change the naming scheme to just %T
click OK
your table now looks like (ignoring optional steps):
Sum(val1) Sum(val2)
6 15
choose another transform, this time Unpivot, and click **Add...*
add all columns to Columns to transform
click OK
now you have:
Category Value
Sum(val1) 6
Sum(val2) 15
choose one last transform: Calculate new column and click **Add...*
enter your case statement that will determine the description and name the column "Description" or something
click OK
click OK
your final table will resemble:
Category Value Description
Sum(val1) 6 This is the sum of value 1
Sum(val2) 15 This is the sum of value 2
on your bar chart, the category axis expression should be Category and value should be Sum(Value) (assuming you didn't change the column names in step 9)
add a new line to the tooltip with an expression First([Description]), or whatever you named the new column in step 12
whew. it's a lot of steps but it works. the goal is to get the description data into it's own column so you can put it in the tooltip. since your data is aggregated and doesn't exist in its own column, this is the only way I can think of doing it.

Resources