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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
klehar
Helper V
Helper V

quarter vs month switcher

Im trying to design a dashboard where based on my filter selection in column QM with values  "Quarter" or "Month", my calculations on the table would change

My calculation

VAR qm = VALUES('Quarter or Month'[QM])

RETURN
 
CALCULATE (

        [IQ TAT <1 Day]
        ,
        DATEADD ( 'DIM Date'[DATE_KY], -1, qm)
    )


but this is the error i get

 

klehar_0-1752501368176.png

 

 

how can i solve this?

1 ACCEPTED SOLUTION
MasonMA
Super User
Super User

@klehar 

 

Hi, i think the problem is VALUES returns a variable, not a fixed keyword. 

 

You may need to update it to below for another try

VAR qm = SELECTEDVALUE('Quarter or Month'[QM], "None")
RETURN
    SWITCH(
        qm,
        "Month", CALCULATE([IQ TAT <1 Day], DATEADD('DIM Date'[DATE_KY], -1, MONTH)),
        "Quarter", CALCULATE([IQ TAT <1 Day], DATEADD('DIM Date'[DATE_KY], -1, QUARTER)),
        BLANK() 
    )

 Hope this helps:) 

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

You could use a calculation group, with separate items for month and quarter, e.g.

Month =
CALCULATE ( SELECTEDMEASURE(), DATEADD ( 'DIM Date'[DATE_KY], -1, MONTH ) )

Quarter =
CALCULATE ( SELECTEDMEASURE(), DATEADD ( 'DIM Date'[DATE_KY], -1, QUARTER ) )

Then put the calculation group into the slicer instead of the 'Quarter or Month' table you have currently.

Alex_Sawdo
Resolver II
Resolver II

You should be able to accomplish this using a field parameter, rather than a DAX measure/column. To do this, at the top of the screen go to this path: Modeling->New parameter->Fields. Then, select your Month and Quarter fields (assuming you have a date dimension in your model). You will then have a field parameter that lets you dynamically choose between either the Month or Quarter column in your date dimension. 

Here's the documentation for Field Parameters as well, if you want to look further into them: Use report readers to change visuals (preview) - Power BI | Microsoft Learn

MasonMA
Super User
Super User

@klehar 

 

Hi, i think the problem is VALUES returns a variable, not a fixed keyword. 

 

You may need to update it to below for another try

VAR qm = SELECTEDVALUE('Quarter or Month'[QM], "None")
RETURN
    SWITCH(
        qm,
        "Month", CALCULATE([IQ TAT <1 Day], DATEADD('DIM Date'[DATE_KY], -1, MONTH)),
        "Quarter", CALCULATE([IQ TAT <1 Day], DATEADD('DIM Date'[DATE_KY], -1, QUARTER)),
        BLANK() 
    )

 Hope this helps:) 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.