Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I have a card visualization that shows the value based on the year selection. I have a slicer of the year (values are last 5 years- 2017, 2018, 2019, 2020, 2021). The slicer is having multiple selection options. I want to show the value of each year when a single selection of years is done, but when multiple years are selected, I want to see the value of the latest year (2021) (no sum or avg or count or first or last). Please help.
Solved! Go to Solution.
You will need a measure, something along these lines.
Display Amount =
VAR _Years =
COUNTROWS ( DISTINCT ( Table[Year] ) )
RETURN
SWITCH (
TRUE (),
_Years = 1, [Value Measure],
_Years > 1, CALCULATE ( [Value Measure], Table[Year] = 2021 )
)
Thanks a lot.. Its working now.
You need a measure to sum the value.
Value Meausure = SUM ( XYZ[Value] )
Then the measure to read the selection and display the correct version of the sum.
Display Measure =
VAR _Years =
COUNTROWS ( DISTINCT ( XYZ[Year] ) )
RETURN
SWITCH (
TRUE (),
_Years = 1, [Value Meausure],
_Years > 1, CALCULATE ( [Value Meausure], XYZ[Year] = 2021 )
)
I have attached my sample file for you to look at.
You will need a measure, something along these lines.
Display Amount =
VAR _Years =
COUNTROWS ( DISTINCT ( Table[Year] ) )
RETURN
SWITCH (
TRUE (),
_Years = 1, [Value Measure],
_Years > 1, CALCULATE ( [Value Measure], Table[Year] = 2021 )
)
I am still getting the error. This is my table (Table name XYZ).
This is my year selection slicer.
I created a new measure as below.
I am not getting the output. It would be great if you can provide detailed steps after creating the measure.
| User | Count |
|---|---|
| 60 | |
| 46 | |
| 32 | |
| 16 | |
| 16 |
| User | Count |
|---|---|
| 82 | |
| 68 | |
| 43 | |
| 26 | |
| 25 |