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
maserr
Helper IV
Helper IV

Filtering by month and previous ones

Dear all,

 

I would like to filter on my slice by month and that my visuals showing all months of the year until the one chosen. If it is february I would like to see on the graphics the months od January and February.

 

Thanks you,

1 ACCEPTED SOLUTION

Hi , @maserr 

Here I take four months as an example.  
pbxi attached

 

Try steps as below:

1.Create a calculate  table as a slicer:

Slicer = DATATABLE("Value",STRING,{{"1January"},{"2February"},{"3March"},{"4April"}})

2.Create a visual control measure" show Control"  as below and put the measure into visual filters:

 

Show Control = 
Var YM =
    SELECTEDVALUE(financials[Date])

Return  
    SWITCH(
        SELECTEDVALUE(Slicer[Month]),
        "1January Month",IF(
            MONTH(YM)<=1,1,-1),
        "2February",IF(
            MONTH(YM)<=2,1,-1),
        "3March",IF(
            MONTH(YM)<=3,1,-1),
        "4April",IF(
            MONTH(YM)<=4,1,-1),
            1
    )
        

 

 

23.png

 

3.it  will show as below:

24.png

 

Best Regards,
Community Support Team _ Eason
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

3 REPLIES 3
amitchandak
Super User
Super User

Try. Assuming you month is coming from the date dimension

measure =
var _max = maxx('Date','Date'[Date])
var _min = date(year(_max),month(_max)-1,1)

return 
calculate([measure],filter(all('Date'), 'Date'[Date]>= _min && 'Date'[Date]<= _max))

Thanks for your quick response, but which are the next steps once i have created the measure? it does not work on my visual.

 

Thanks another time

Hi , @maserr 

Here I take four months as an example.  
pbxi attached

 

Try steps as below:

1.Create a calculate  table as a slicer:

Slicer = DATATABLE("Value",STRING,{{"1January"},{"2February"},{"3March"},{"4April"}})

2.Create a visual control measure" show Control"  as below and put the measure into visual filters:

 

Show Control = 
Var YM =
    SELECTEDVALUE(financials[Date])

Return  
    SWITCH(
        SELECTEDVALUE(Slicer[Month]),
        "1January Month",IF(
            MONTH(YM)<=1,1,-1),
        "2February",IF(
            MONTH(YM)<=2,1,-1),
        "3March",IF(
            MONTH(YM)<=3,1,-1),
        "4April",IF(
            MONTH(YM)<=4,1,-1),
            1
    )
        

 

 

23.png

 

3.it  will show as below:

24.png

 

Best Regards,
Community Support Team _ Eason
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.