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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mark_carlisle
Advocate IV
Advocate IV

Date What If Parameter

I've created 3 What If parameters Date - Year, Date - Month, and Date - Day.

 

I have a two measures already to calculate the total cases pre and post a date, these are;

 

 

Total Cases (Post 16/03) = 
CALCULATE (
    [Total Cases (Distinct)],
    ALL ( 'Calendar' ),
    FILTER ( 'Calendar', 'Calendar'[Date] >= DATE ( 2020, 03, 16 ) )
)
Total Cases (Pre 16/03) = 
CALCULATE (
    [Total Cases (Distinct)],
    ALL ( 'Calendar' ),
    FILTER (
        'Calendar',
        AND (
            'Calendar'[Date] >= DATE ( 2020, 01, 01 ),
            'Calendar'[Date] < DATE ( 2020, 03, 16 )
        )
    )
)

 

 

What I wanted to do was replace the hardcoded date with the values from the What If parameters so the users can move this date, so if we take Total Cases (Pre 16/03) I've done this;

 

 

Total Cases (Pre 16/03) = 
CALCULATE (
    [Total Cases(Distinct)],
    ALL ( 'Calendar' ),
    FILTER (
        'Calendar',
        AND (
            'Calendar'[Date] >= DATE ( 2020, 01, 01 ),
            'Calendar'[Date] < DATE ( [Date - Year Value], [Date - Month Value], [Date - Day Value] )
        )
    )
)

 

 

This returns nothing and when troubleshooting its the parameters causing the issue as it returns a blank calendar table.

 

Is what I want to do possible?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Try:

 

Total Cases (Pre 16/03) = 
VAR __Year = SELECTEDVALUE([Date - Year Value])
VAR __Month = SELECTEDVALUE([Date - Month Value])
VAR __Day = SELECTEDVALUE([Date - Day Value])
CALCULATE (
    [Total Cases(Distinct)],
    ALL ( 'Calendar' ),
    FILTER (
        'Calendar',
        AND (
            'Calendar'[Date] >= DATE ( 2020, 01, 01 ),
            'Calendar'[Date] < DATE ( __Year, __Month, __Day )
        )
    )
)


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
mark_carlisle
Advocate IV
Advocate IV

Tried the same thing earlier and it didn't work, but tried yours anyway and then realised it was because I didn't have the Sync Slicers option set correctly!

 

Thanks for the help.

Greg_Deckler
Community Champion
Community Champion

Try:

 

Total Cases (Pre 16/03) = 
VAR __Year = SELECTEDVALUE([Date - Year Value])
VAR __Month = SELECTEDVALUE([Date - Month Value])
VAR __Day = SELECTEDVALUE([Date - Day Value])
CALCULATE (
    [Total Cases(Distinct)],
    ALL ( 'Calendar' ),
    FILTER (
        'Calendar',
        AND (
            'Calendar'[Date] >= DATE ( 2020, 01, 01 ),
            'Calendar'[Date] < DATE ( __Year, __Month, __Day )
        )
    )
)


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.