Forum Discussion
Dax Measure -
I have the following DAX measure:
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.
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!
2 Replies
- amitchandakSuper 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)) - v-karpurapudCommunity 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.
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!