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
edant
Regular Visitor

Card visual not filtered by slicer

Hello,

 

I created a sample of data using a pre-defined dates slicer in order to show results from today/last week/last month/last quarter.

edant_1-1642620452811.png

 

I created a flag measure which I used as a filter on the chart visual:

edant_3-1642624448542.png

 

flag = 
SWITCH (
    MAX ( 'slicer'[slicer] ),
    "Today", IF ( MAX ( 'DateCalendar'[Date] ) = TODAY (), 1 ),
    "Last Week",
        IF (
            DATEDIFF ( MAX ( 'DateCalendar'[Date] ), TODAY (), DAY ) <= 7
                && MAX ( 'DateCalendar'[Date] ) <= TODAY (),
            1
        ),
    "Last Month",
        IF (
            DATEDIFF ( MAX ( 'DateCalendar'[Date] ), TODAY (), DAY ) <= 30
                && MAX ( 'DateCalendar'[Date] ) < TODAY (),
            1
        ),
    "Last Quarter",
        IF (
            DATEDIFF ( MAX ( 'DateCalendar'[Date] ), TODAY (), DAY ) <= 90
                && MAX ( 'DateCalendar'[Date] ) < TODAY (),
            1
        )
)

 

Now, when I'm changing the slicer between the pre-defined parameter (mentioned above), it worked perfectly on the chart but not on the card. (I cannot use it there)

I guess it has something to do with the fact that there is no relationship between the slicer table to the rest of the tables.

edant_2-1642620512158.png

I'm pretty much lost with this issue.

How do I make the slicer work on the card visual as well? When I try to use the flag on the card visual, I cannot set the value to "Is = 1". (it's blocked)

 

Here is the report for download - 

Report Example 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @edant ,

 

Since slicer table is not connected with your action table so have to update your card visual code like below:-

 

CountAllFlowsTest =
SWITCH (
    MAX ( 'slicer'[slicer] ),
    "Today",
        CALCULATE (
            COUNT ( 'Action'[ID] ),
            FILTER ( DateCalendar, 'DateCalendar'[Date] = TODAY () )
        ),
    "Last Week",
        CALCULATE (
            COUNT ( 'Action'[ID] ),
            FILTER (
                DateCalendar,
                DATEDIFF ( 'DateCalendar'[Date], TODAY (), DAY ) <= 7
                    && 'DateCalendar'[Date] <= TODAY ()
            )
        ),
    "Last Month",
        CALCULATE (
            COUNT ( 'Action'[ID] ),
            FILTER (
                DateCalendar,
                DATEDIFF ( 'DateCalendar'[Date], TODAY (), DAY ) <= 30
                    && 'DateCalendar'[Date] < TODAY ()
            )
        ),
    "Last Quarter",
        CALCULATE (
            COUNT ( 'Action'[ID] ),
            FILTER (
                DateCalendar,
                DATEDIFF ( 'DateCalendar'[Date], TODAY (), DAY ) <= 90
                    && 'DateCalendar'[Date] < TODAY ()
            )
        )
)

 

Output:-

image.png

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

Hi @edant ,

 

Since slicer table is not connected with your action table so have to update your card visual code like below:-

 

CountAllFlowsTest =
SWITCH (
    MAX ( 'slicer'[slicer] ),
    "Today",
        CALCULATE (
            COUNT ( 'Action'[ID] ),
            FILTER ( DateCalendar, 'DateCalendar'[Date] = TODAY () )
        ),
    "Last Week",
        CALCULATE (
            COUNT ( 'Action'[ID] ),
            FILTER (
                DateCalendar,
                DATEDIFF ( 'DateCalendar'[Date], TODAY (), DAY ) <= 7
                    && 'DateCalendar'[Date] <= TODAY ()
            )
        ),
    "Last Month",
        CALCULATE (
            COUNT ( 'Action'[ID] ),
            FILTER (
                DateCalendar,
                DATEDIFF ( 'DateCalendar'[Date], TODAY (), DAY ) <= 30
                    && 'DateCalendar'[Date] < TODAY ()
            )
        ),
    "Last Quarter",
        CALCULATE (
            COUNT ( 'Action'[ID] ),
            FILTER (
                DateCalendar,
                DATEDIFF ( 'DateCalendar'[Date], TODAY (), DAY ) <= 90
                    && 'DateCalendar'[Date] < TODAY ()
            )
        )
)

 

Output:-

image.png

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Brilliant, that works like a charm.

Many thanks, Samarth. 🙂

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.