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
Caesarul
Helper II
Helper II

Apply Filter "is 1" on a Card Visual

Hi, 

 

I've been watching this tutorial on how to make a preset value button panel for certain date ranges

https://www.youtube.com/watch?v=nocsNBF_NkE

 

The Sample File is here: https://github.com/MarkWilcock/lbag-online/tree/master/M%26G%20Results

 

I've succesfully implemented it, but I'm having trouble adding the Measure as a Filter in the Card Visuals 

 

When I try to click on the options there to choose "is" it doesn't open up. 

 

Is this a bug? Is there a way to implement this feature to cards as well?

 

Caesarul_0-1670929523650.png

 

Thank you!

 

1 ACCEPTED SOLUTION

Hi @Caesarul ,

 

Here I download your sample to have a test and I could reproduce your issue. You can see that I count [Date] in card visual and I try to add [Preset Value] in it as a visual level filter, it doesn't work. 

RicoZhou_0-1671005873869.png

As far as I know, measure need to be expand in other visuals like table/matrix or charts. Card visual will only return a single value, so measure filter may not support. 

So I suggest you to create a new measure and add [Preset Value] =1 in filter field in your code.

Measure = CALCULATE(COUNT('M&G'[Date]),FILTER('M&G',[Preset Value] = 1))

Result is as below.

RicoZhou_1-1671006049520.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

7 REPLIES 7
latimeria
Solution Specialist
Solution Specialist

Hi @Caesarul ,

Without sample, we can guess
Is 'Preset' value a number? My assumption it is a true/falsevalue, not a number. Wrap the formula with INT() to get a number.

 

Hope this help.

The Sample File is here: https://github.com/MarkWilcock/lbag-online/tree/master/M%26G%20Results

The Measure for Preset Value is: 

 

Preset Value =
VAR presetCode = SELECTEDVALUE('Range'[Range])
VAR refdate = MAX('Combined Entity Employee'[Month])
VAR todayDate = TODAY()
VAR daysDiff = DATEDIFF(refdate, todayDate, DAY)
VAR result =
SWITCH(
    presetCode,
    "1M", IF(daysDiff < 31, 1),
    "3M", IF(daysDiff < 92, 1),
    "6M", IF(daysDiff < 183, 1),
    "1Y", IF(daysDiff < 366, 1),
    "YTD", IF(YEAR(refdate) = YEAR(todayDate) && refdate <= todayDate, 1),
    "Max", 1,
    0)
RETURN result
 
 
So when I give a visual chart or table/matrix the filter "is 1" the range panel will trigger the last 3 months, 6 months, etc. as per the video tutorial: https://www.youtube.com/watch?v=nocsNBF_NkE

Hi @Caesarul ,

 

Here I download your sample to have a test and I could reproduce your issue. You can see that I count [Date] in card visual and I try to add [Preset Value] in it as a visual level filter, it doesn't work. 

RicoZhou_0-1671005873869.png

As far as I know, measure need to be expand in other visuals like table/matrix or charts. Card visual will only return a single value, so measure filter may not support. 

So I suggest you to create a new measure and add [Preset Value] =1 in filter field in your code.

Measure = CALCULATE(COUNT('M&G'[Date]),FILTER('M&G',[Preset Value] = 1))

Result is as below.

RicoZhou_1-1671006049520.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you @v-rzhou-msft !!! That's brilliant !!! I'll try it out and follow-up as soon as possible. 

Do you have any idea if I can sync the Preset Code panel with my Date Slicer? 

I want to give my stakeholders the opportunity to use the preset codes and the date slicer as well (if they need to), but they seem to filter one another instead of syncing. 

I've opened another thread here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Sync-Preset-Date-Value-with-a-Date-between-Sl...

Caesarul_0-1671006780457.png

 

Thanky a lot! This is the 2nd time you save me !!! 

 

Try changing the formula like this

"1M"IF(daysDiff < 311,0), and so on.

"1M", IF(daysDiff < 31, 1) => if preset code= "1M", if daysdiff = 31 for example then preset value = false!!!

 

 

Thanks @latimeria 

It didn't work though 😞 

how many rows in preset value? blank row?

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.