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

filter where date = today

I have table of data.

i am using chiclet slicer for the button look

i want to be able to select a button to filter the table for entries with todays date

i created a new column and applied this

CurrentDate = IF('QR Scanning'[DateTime].[Date] = today(), "Today", "All")
this provides 2 buttons in the slicer, Today and All
Clicking Today will filter for the entries with todays date, but clicking All will show all entries other than todays date
how do i get either 
1 button - when clicked, show todays entries, when deselected shows everything
2 buttons - today shows today entries, all shows all entries
1 ACCEPTED SOLUTION

Hi @braddo81 

I think calculated column is not a good way to achieve your goal. You can try to build a filter measure.

My Sample:

1.png

Firstly, let's build a new table to create a slicer.

Table = {"All","Today"}

Then create a measure.

Filter =
VAR _CurrentDateTime =
    MAX ( 'QR Scanning'[DateTime] )
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Table'[Slicer] ),
        "All", 1,
        "Today",
            IF (
                DATE ( YEAR ( _CurrentDateTime ), MONTH ( _CurrentDateTime ), DAY ( _CurrentDateTime ) )
                    = TODAY (),
                1,
                0
            ),
        0
    )

Build your visual and add this measure into filter field. Set this measure to show items when value equal to 1.

Select ALL

1.png

Select Today.

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

5 REPLIES 5
amitchandak
Super User
Super User

@braddo81 , Create a slicer with Orientation as horizontal and see if that can solve the purpose

https://docs.microsoft.com/en-us/power-bi/power-bi-slicer-filter-responsive

i don't see how that helps my formula 

i need to have 2 options with the filter

1. see todays data

2 see all data

Greg_Deckler
Super User
Super User

@braddo81 Create bookmarks for Today versus All and tie the buttons to those bookmarks.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

the buttons are ok as they are, my issue is the data the All returns

as it is tied to the query - 

CurrentDate = IF('QR Scanning'[DateTime].[Date] = today(), "Today", "All")
all shows everything other than today - i want it to show all
so can i get a better formula? or filter differently?

Hi @braddo81 

I think calculated column is not a good way to achieve your goal. You can try to build a filter measure.

My Sample:

1.png

Firstly, let's build a new table to create a slicer.

Table = {"All","Today"}

Then create a measure.

Filter =
VAR _CurrentDateTime =
    MAX ( 'QR Scanning'[DateTime] )
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Table'[Slicer] ),
        "All", 1,
        "Today",
            IF (
                DATE ( YEAR ( _CurrentDateTime ), MONTH ( _CurrentDateTime ), DAY ( _CurrentDateTime ) )
                    = TODAY (),
                1,
                0
            ),
        0
    )

Build your visual and add this measure into filter field. Set this measure to show items when value equal to 1.

Select ALL

1.png

Select Today.

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

 

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.