Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
David83300
Frequent Visitor

YTD filter based on the selected month

Hello,

 

I'm trying to create a dynamic time filter based on the selected month (Always one month selected in the report):

MTD: Selected month

YTD: Janv - to selected month (No cumulation !)

FY: Janv - Dec

 

First I tried with calculation group but I always get cumulated YTD result. Now I try with a DAX table but I can't link the selected month in the DAX table...

 

Model:

David83300_1-1737639204491.png

 

DAX Filter table:

MonthFilter = 
Var _SelectedMonth= max(SelectedMonth[SelectedMonth])

Var _MonthFilter = UNION(

ADDCOLUMNS(
    SELECTCOLUMNS(GENERATESERIES ( _SelectedMonth,_SelectedMonth,1 ) ,"Mois",INT([Value]))
,"MonthFilter","MTD"
,"Order",1)

,ADDCOLUMNS(
    SELECTCOLUMNS(GENERATESERIES ( 1,_SelectedMonth,1 ) ,"Mois",INT([Value]))
,"MonthFilter","YTD"
,"Order",2)


,ADDCOLUMNS(
    SELECTCOLUMNS(GENERATESERIES ( 1, 12 ,1 ) ,"Mois",INT([Value]))
,"MonthFilter","Full Year"
,"Order",3)
)

Return
_MonthFilter

 

 

Result:

David83300_2-1737639297714.png

 

Thanks for your help 🙂

 

 

7 REPLIES 7
David83300
Frequent Visitor

Thanks @Anonymous your solution works. But it's not very practical, I would prefer to avoid adding visual filters everywhere 😕 But maybe this is the only way ?

And by the way it's not working anymore if I switch to quarter dimension instead of month

Anonymous
Not applicable

Hi @David83300 ,

 

Since your requirement requires matrix visual for dynamic display, I suggest you try using measure to get dynamic results or you can try to create custom visuals by yourself.

If you want to switch to quarter dimension, we can update the measure and the MonthFilter table to achieve your goal.

Please show us a screenshot with the result you want switching to quarter dimension.

 

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.

 

Hello,

Thanks @Anonymous , I added a Quarter dimension in the PBIX. As you can see it's not working right now

 

David83300_0-1738169169631.png

 

https://we.tl/t-OeO6cwyLNw

Anonymous
Not applicable

Hi @David83300 ,

 

Here I update my sample, you can download and check the attachment.

vrzhoumsft_0-1738574788671.png

vrzhoumsft_0-1738575001240.png

If this reply still couldn't help you solve your issue, the transfer has been expired, please share again with us.

 

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.

 

Hi @Anonymous 

Thanks but it's only working if I keep the month dimension in the chart. 

I need something that can work without the month dimension, is that possible ?

 

David83300_0-1738604606648.png

 

David83300
Frequent Visitor

Example PBIX file:

https://we.tl/t-x9zpYv40XQ

 

Anonymous
Not applicable

Hi @David83300 ,

 

I suggest you to create a Monthfilter table as below.

MonthFilter = 
VAR _MonthFilter =
DATATABLE(
    "MonthFilter",STRING,
    "Order",INTEGER,
    {
        {"MTD",1},
        {"YTD",2},
        {"Full Year",3}
        }
)
Return
_MonthFilter

Then create a measure to filter your visual in visual level filter and set it to show items when value = 1.

Measure = 
SWITCH(
    MAX(MonthFilter[Order]),
    1,IF(MAX(DIM_DATE[MONTH]) = SELECTEDVALUE(SelectedMonth[SelectedMonth]),1,0),
    2,IF(MAX(DIM_DATE[MONTH]) <= SELECTEDVALUE(SelectedMonth[SelectedMonth]),1,0),
    3,1)

Result is as below.

vrzhoumsft_0-1737698782591.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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.