Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Trying to find a way to change a ratio calculation with slicer which is having values from a column.
For example: i have 3 values in a column: apples, pears, oranges and another column where i found which from these fruits are eaten or not, flaged with 1/0.
I want a slicer to select the fruit and get the ratio of that eaten fruit out of total. Total ratio of eaten apples is calculated like this: Total number of eaten apples / Total number of apples. From the slicer i want to change this calculation dynamically for each fruit.
Solved! Go to Solution.
try this in measure,
Ratio of eaten fruit =
VAR _eaten =
CALCULATE ( COUNT ( Table[Fruits] ), Table[Flag] = 1 )
VAR _all =
CALCULATE ( COUNT ( Table[Fruits] ), ALL ( Table) )
VAR _result =
DIVIDE ( _eaten, _all )
RETURN
_result
Thanks,
Arul
@Arul
Sure, but i have to show you the real data tables i use:
@Arul I've debug a little, and the _all variable doesn't work as intended, it should filter by the slicer value, i've got 1M results for it and the result doesn't change from the slicer , should be 5857
I've done it. I change _all variable with "
try this in measure,
Ratio of eaten fruit =
VAR _eaten =
CALCULATE ( COUNT ( Table[Fruits] ), Table[Flag] = 1 )
VAR _all =
CALCULATE ( COUNT ( Table[Fruits] ), ALL ( Table) )
VAR _result =
DIVIDE ( _eaten, _all )
RETURN
_result
Thanks,
Arul
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
101 | |
78 | |
69 | |
63 |
User | Count |
---|---|
141 | |
106 | |
101 | |
85 | |
72 |