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

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.

Reply
Elo4
Frequent Visitor

Hide visual with IF ISFILTERED and SELECTEDVALUE by using a multiple slicer selection

I have 3 matrix with KPIs (rows) and a slicer with month.

I want to hide the KPI in the third matrix with a card (white background and text "data available as from February") IF the selected month is before February. (because data are only available after February)

We can select multiple month in the slicer.

Fiscal Year is starting on October.

hide if isfiltered and selectedvalue.JPG

If I select only october or only november for example -> it´s working and KPIs are hidden by the card (see screenshot).

But my problem is when I select multiple month (october + november), it´s not working anymore.

Moreover I want it to disappear if Febuary (or month after) is selected: so for example December+January+February

 

I tried different ways but combinations are not working (not reacting).

Message for the card:

IF(
ISFILTERED(Kalender[Monatname]) && SELECTEDVALUE(Kalender[Monatname]) IN {"Oktober", "November", "Dezember", "Januar"}
|| SELECTEDVALUE(Kalender[Monatname]) IN {"Oktober", "November"}
|| SELECTEDVALUE(Kalender[Monatname]) IN {"Oktober", "November", "Dezember"}
|| SELECTEDVALUE(Kalender[Monatname]) IN {"November", "Dezember"}
|| SELECTEDVALUE(Kalender[Monatname]) IN {"November", "Dezember", "Januar"}
|| SELECTEDVALUE(Kalender[Monatname]) IN {"Dezember", "Januar"}
,"Daten ab Februar 2022 vorhanden",
"")
 
White Background for the card: (here another way with number of month instead of name but also not working on multiple selection)
IF(
ISFILTERED(Kalender[Monatname]) && SELECTEDVALUE(Kalender[Monat]) IN {10,11,12,1}
|| SELECTEDVALUE(Kalender[Monatname]) IN {10,11}
|| SELECTEDVALUE(Kalender[Monatname]) IN {10,11,12}
|| SELECTEDVALUE(Kalender[Monatname]) IN {11,12}
|| SELECTEDVALUE(Kalender[Monatname]) IN {11,12,1}
|| SELECTEDVALUE(Kalender[Monatname]) IN {12,1}
, "White"
,"#FFFFFF00")
 
I also tried with 
IF(
ISFILTERED(Kalender[Monatname]) && SELECTEDVALUE(Kalender[Monatname]) = "October"
|| SELECTEDVALUE(Kalender[Monatname]) = "November"
 
but it is not working with combination of month.
 
Any ideas on how to write the correct DAX code to get reaction on multiple month selection (before and after February)
 
Thanks a lot!
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Elo4 

 

Your measure doesn't work because of the SELECTEDVALUE function. It returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult. So when selecting multiple months, it returns the default blank value rather than the selected months. 

 

To resolve this problem, you can use MAX instead of SELECTEDVALUE. You can add a fiscal month number column to the calendar table which starts at 1 in October and ends at 12 in September. Then the measures could be simpler. 

Word Measure = IF(MAX('Calendar'[Fiscal Month Numer])<5,"Daten ab Februar 2022 vorhanden","")
Card Color = IF(MAX('Calendar'[Fiscal Month Numer])<5,"White","#FFFFFF00")

 

Result: (I enable the border of the card to make it visible. Sample file has been attached at bottom.)

vjingzhang_0-1656054197227.png

vjingzhang_1-1656054229337.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Elo4 

 

Your measure doesn't work because of the SELECTEDVALUE function. It returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult. So when selecting multiple months, it returns the default blank value rather than the selected months. 

 

To resolve this problem, you can use MAX instead of SELECTEDVALUE. You can add a fiscal month number column to the calendar table which starts at 1 in October and ends at 12 in September. Then the measures could be simpler. 

Word Measure = IF(MAX('Calendar'[Fiscal Month Numer])<5,"Daten ab Februar 2022 vorhanden","")
Card Color = IF(MAX('Calendar'[Fiscal Month Numer])<5,"White","#FFFFFF00")

 

Result: (I enable the border of the card to make it visible. Sample file has been attached at bottom.)

vjingzhang_0-1656054197227.png

vjingzhang_1-1656054229337.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Hi v-jingzhang,

 

it works! thanks a lot for helping me

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.