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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply

Dax Measure -

I have the following DAX measure: 

 

Premium =
Var Selected_Month_Number = SELECTEDVALUE(Dim_Date[Month No])
RETURN
CALCULATE(
    SUM('Data'[GBP Premium]), 'Contract Detail'[Starting Month Number] <= Selected_Month_Number && 'Data'[Ending Month Number] >= Selected_Month_Number,   REMOVEFILTERS(Dim_Date))
 
The Starting Month Number and Ending Month number are both column measures.
 
If the end Month Number is 0, I would like to update the above formula to use the value from the Gross Sales column instead
 
How do I create this DAX measure? 
1 ACCEPTED SOLUTION
v-karpurapud
Community Support
Community Support

Hi @zameenakarmali 

Thank you for reaching out to the Microsoft Fabric Community Forum.

Regarding your query on creating DAX measure that
dynamically evaluates premium values based on a selected month and the contract's start and end month numbers.

 

while I’m not fully aware of the exact structure of your dataset, I’ve created a sample .pbix file to demonstrate one possible solution.

Please try the below DAX:

 

Premium =

VAR Selected_Month_Number = SELECTEDVALUE(Dim_Date[Month No])

RETURN

CALCULATE (

    SUMX (

        'Data',

        SWITCH (

            TRUE(),

            'Data'[Ending Month Number] = 0, 'Data'[Gross Sales],

            'Data'[Starting Month Number] <= Selected_Month_Number

                && 'Data'[Ending Month Number] >= Selected_Month_Number, 'Data'[GBP Premium],

            0

        )

    ),

    REMOVEFILTERS(Dim_Date)

)

       

 

I’ve attached a few screenshots and the .pbix file demonstrating this logic. Please review them to see if this solution aligns with your requirements.

vkarpurapud_0-1745298285843.png          vkarpurapud_1-1745298292905.png

 

If this doesn’t fully meet your needs, could you kindly share a sample of your data and more detailed context? That would help us provide a more accurate solution.


If this response resolves your query, kindly mark it as Accepted Solution to help other community members. A Kudos is also appreciated if you found the response helpful.

 

Additionally, thank you @amitchandak for your prompt response.

 

Thank You!

 

 

View solution in original post

2 REPLIES 2
v-karpurapud
Community Support
Community Support

Hi @zameenakarmali 

Thank you for reaching out to the Microsoft Fabric Community Forum.

Regarding your query on creating DAX measure that
dynamically evaluates premium values based on a selected month and the contract's start and end month numbers.

 

while I’m not fully aware of the exact structure of your dataset, I’ve created a sample .pbix file to demonstrate one possible solution.

Please try the below DAX:

 

Premium =

VAR Selected_Month_Number = SELECTEDVALUE(Dim_Date[Month No])

RETURN

CALCULATE (

    SUMX (

        'Data',

        SWITCH (

            TRUE(),

            'Data'[Ending Month Number] = 0, 'Data'[Gross Sales],

            'Data'[Starting Month Number] <= Selected_Month_Number

                && 'Data'[Ending Month Number] >= Selected_Month_Number, 'Data'[GBP Premium],

            0

        )

    ),

    REMOVEFILTERS(Dim_Date)

)

       

 

I’ve attached a few screenshots and the .pbix file demonstrating this logic. Please review them to see if this solution aligns with your requirements.

vkarpurapud_0-1745298285843.png          vkarpurapud_1-1745298292905.png

 

If this doesn’t fully meet your needs, could you kindly share a sample of your data and more detailed context? That would help us provide a more accurate solution.


If this response resolves your query, kindly mark it as Accepted Solution to help other community members. A Kudos is also appreciated if you found the response helpful.

 

Additionally, thank you @amitchandak for your prompt response.

 

Thank You!

 

 

amitchandak
Super User
Super User

@zameenakarmali , try like

RETURN
CALCULATE(
SUMX('Data', if('Data'[Ending Month Number] =0,'Data'[Gross]  , 'Data'[GBP Premium]) ), 'Contract Detail'[Starting Month Number] <= Selected_Month_Number && 'Data'[Ending Month Number] >= Selected_Month_Number, REMOVEFILTERS(Dim_Date))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.