Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
chiranjeevkar
New Member

Conditional Card Visualisation issue

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.

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@chiranjeevkar 

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 )
    )

 

View solution in original post

4 REPLIES 4
chiranjeevkar
New Member

Thanks a lot.. Its working now.

jdbuchanan71
Super User
Super User

@chiranjeevkar 

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 )
    )

2022-02-05_20-32-35.jpg

I have attached my sample file for you to look at.

jdbuchanan71
Super User
Super User

@chiranjeevkar 

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).

chiranjeevkar_0-1644109458931.png

chiranjeevkar_1-1644109509539.png

This is my year selection slicer.

I created a new measure as below.

chiranjeevkar_2-1644109629010.png

I am not getting the output. It would be great if you can provide detailed steps after creating the measure.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.