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
Anonymous
Not applicable

Use filters or slicers to include several different time periods in a table

Hi,

I have a table with dates and several different columns. 
I would like to only include the first x dates, the middle x dates and the last x dates in that table.

Is it possible to add slicers or filters on the page to achieve this?
It needs to be user input friendly to select the range of the three different time periods.

 

Thanks.

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

I'm afraid it can't be realized just by filter or slicer as you wanna present 3 different periods of time,you need to create a new table instead,and the dax expression is as below:

 

Table 2 = 
VAR k =
    ADDCOLUMNS (
        'Table',
        "filter",
        VAR d1 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 1 )
        VAR d2 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 2 )
        VAR d3 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 3 )
        VAR d10 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 10 )
        VAR d11 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 11 )
        VAR d12 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 12 )
        VAR e1 =
            CALCULATE (
                MAX ( 'Table'[Date] ),
                FILTER (
                    'Table',
                    [Date].[Year] = EARLIER ( [Date].[Year] )
                        && [Date].[Month] = EARLIER ( [Date].[Month] )
                )
            )
        VAR e11 = e1 - 1
        VAR e12 = e1 - 2
        VAR e13 = e1 - 3
        VAR t = { d1, d2, d3, d10, d11, d12, e1, e12, e13 }
        RETURN
            IF ( [Date] IN t, 1, 0 )
    )
RETURN
    SELECTCOLUMNS (
        FILTER ( k, [filter] = 1 ),
        "Date", [Date],
        "City", [City],
        "Vist", [Visitor]
    )

 

Then you will see:

11.png

 

 
Best Regards,
Kelly

 

View solution in original post

6 REPLIES 6
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you wanna show as below?

131.png

If so,you only need to edit the interactions between the slicer and the table, if you dont want the table be filtered by the slicer,just click the slicer and and choose the interaction as below:

 

132.png

Best Regards,
Kelly

Anonymous
Not applicable

Looking for something like this:
Full table:

Date

Value
1/1/202014
1/2/20202
1/3/202012
1/4/202014
1/5/202017
1/6/202016
1/7/20202
1/8/20206
1/9/20209
1/10/202014
1/11/202017
1/12/202018
1/13/202020
1/14/20209
1/15/20203
1/16/202018
1/17/202013
1/18/20201
1/19/202012
1/20/202016
1/21/202011
1/22/202015
1/23/202013
1/24/202015
1/25/20205
1/26/20201
1/27/202020
1/28/20207
1/29/202012
1/30/202012




Then I would like the option to filter for several specific date intervals such as this output:

DateValue
1/1/202014
1/2/20202
1/3/202012
1/10/202014
1/11/202017
1/12/202018
1/28/20207
1/29/202012
1/30/202012

Hi @Anonymous ,

 

I'm afraid it can't be realized just by filter or slicer as you wanna present 3 different periods of time,you need to create a new table instead,and the dax expression is as below:

 

Table 2 = 
VAR k =
    ADDCOLUMNS (
        'Table',
        "filter",
        VAR d1 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 1 )
        VAR d2 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 2 )
        VAR d3 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 3 )
        VAR d10 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 10 )
        VAR d11 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 11 )
        VAR d12 =
            DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 12 )
        VAR e1 =
            CALCULATE (
                MAX ( 'Table'[Date] ),
                FILTER (
                    'Table',
                    [Date].[Year] = EARLIER ( [Date].[Year] )
                        && [Date].[Month] = EARLIER ( [Date].[Month] )
                )
            )
        VAR e11 = e1 - 1
        VAR e12 = e1 - 2
        VAR e13 = e1 - 3
        VAR t = { d1, d2, d3, d10, d11, d12, e1, e12, e13 }
        RETURN
            IF ( [Date] IN t, 1, 0 )
    )
RETURN
    SELECTCOLUMNS (
        FILTER ( k, [filter] = 1 ),
        "Date", [Date],
        "City", [City],
        "Vist", [Visitor]
    )

 

Then you will see:

11.png

 

 
Best Regards,
Kelly

 

Anonymous
Not applicable

It's something similar to this I'm looking for, but I would like to have it all combined in one table, not three seperate tables.

Hi @Anonymous ,

 

Can you show me your expected result?

 

Best Regards,
Kelly

KHorseman
Community Champion
Community Champion

I would start by creating a dedicated date table to offload the heavy lifting from your main data table. Create a relationship between the date column and a column of contiguous dates in the date table. Then create other columns as labels to work as filters. I don't know the specifics of the behavior you want but you could use a date diff column that labels each row with how many days ago it is, then have a number slicer to select a range of those for instance. Or if you want to have set blocks of dates (for instance if you want a button that always selects the last 30 days) you could have a column that labels all those dates with "Last 30 Days" and use that as a slicer.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.