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
bijaymaharjan
Regular Visitor

Need help to determine DAX to solve the following problem

I have 2 tables, a Claims table and a Date table. Claims table includes Claim Number, Loss amounts, Policy Effective Date and Transaction Effective Date. A Claim can have multiple Transaction Effective Date but only a single Policy Effective Date. Each Claim number is unique. The Claims table has an Active Relationship with Date table using Transaction Effective Date and an Inactive relationship using Policy Effective Date.
Requirements: 1. Need a measure to calculate the total loss based on the Policy Effective dates of the claims. The Power Bi will have an Transaction Date filter. When the filter gets applied, the Total Loss based on Policy Effective date needs to re-calculate so show the total based on the Transaction Date filter. Also, if the total loss of a claim is above 2M then the claim should be defaulted to 2M. The Power BI will have Policy Effective Date in Row, Total Loss as the values and Transaction Date as filter.

 
 
Example Table:
Claim_NumberPolicy_Eff_DateTransaction_DateTotal_Incurred
CPZ25003591/5/20252/19/202595000
CPZ25003591/5/20253/7/20250
CPZ25003591/5/20253/7/20250
CPZ25003591/5/20253/7/20250
CPZ25003591/5/20253/6/20253500
CPZ25003591/5/20254/24/20250
CPZ25003591/5/20254/23/2025-1549.900024
CPZ25003591/5/20254/23/20251549.900024
CPZ25003591/5/20254/23/202540000
CPZ25003591/5/20254/23/20251416250
CPZ25003591/5/20254/23/2025605700
CPZ25003591/5/20254/23/2025730000
CPZ25003591/5/20255/5/20250
CPZ25003591/5/20255/20/20250
CPZ25003591/5/20255/23/20250
CPZ25004372/20/20253/31/20252500
CPZ25004372/20/20253/31/202510000
CPZ25004372/20/20254/25/2025165000
CPZ25004372/20/20255/19/20250
CPZ24002391/16/202411/15/202420000
CPZ24002391/16/202411/15/202425000
CPZ24002391/16/20242/4/20250
CPZ24002391/16/20242/3/202525000
CPZ24002391/16/20244/30/202570000
CPZ24002391/16/20245/5/20250
CPZ25003601/20/20252/24/202517500
CPZ25003601/20/20253/21/202580000
CPZ25003601/20/20251/30/20253057.7

Q. I am going to have a Policy Year and then drill down option to show the month's in the year. In this example, say I have a Transaction filter set to 4/30/2025 then the table needs to filter out all the rows with Transaction Date greater than 4/30/2025 and then sum of the Total_Incurred values. One caveat is that if a total_incurred for a claim exceeds 2M then we only take 2M and then add up with the other claim to get the total incurred for the month. The sub-total or grand total can be more than 2M but not the individual claim total. In the following table, January has 2 policies CPZ2500359 and CPZ2500360. The total_incurred for CPZ2500359 will be 2890450 but since the total exceeded 2M we only take 2M. The total incurred for CPZ2500360 is 100557.7. Hence, the total for January 2025 is 2M + 100557.7 = 2100558. This is how I want to show data in a matrix:
Policy Year/MonthTotal Incurred
2024140000
January140000
20252278058
January2100558
February177500
Similarly, if i change the filter to 2/28/2025 then all the rows with Transaction date after 2/28/2025 should be excluded. This is how the data should be when i select this filter:
Policy Year/MonthTotal Incurred
202470000
January70000
2025112500
January112500
February0
6 REPLIES 6
v-kpoloju-msft
Community Support
Community Support

Hi @bijaymaharjan,

Thank you for reaching out to the Microsoft fabric community forum. Also thanks @MarkLaf@SamsonTruong, for those insights on this thread. I reproduced the scenario, and it worked on my end. I used my sample data and successfully implemented it.

outcome:

vkpolojumsft_0-1750312430221.png


I am also including .pbix file for your better understanding, please have a look into it:

If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

Thank you for using Microsoft Community Forum.

Hi @v-kpoloju-msft ,
Thank you for looking in the problem and providing a solution for it but this is not correct. The Total_Incurred value you are showing in the matrix is total based on the Transaction date and not the Policy Effective Date. The date in the matrix should represent the Policy Year and the Total Incurred should be the total of the policy effective date. For example, if we set the filter to be from 11/15/2024 to 3/31/2025, then the table should filter to show all the data that has a transaction date between 11/15/2024 to 3/31/2025 and then the total should be done based on the Policy Effective date. I have included a detail example explanation in my requirements above. I hope you can help me out on this.

bijaymaharjan
Regular Visitor

Hi @SamsonTruong 
Thank you for the answer. Your query worked on getting the result but when I change the data in the filter the matrix does not get updated with the correct numbers. I have re-edited my original request with more clear examples and the desired result. Could you please go over the example description again and the update your query?

MarkLaf
Memorable Member
Memorable Member

If you are concerned about subtotals, then you'll want an iterator version:

 

Incurred_Capped2M = 
CALCULATE( 
    SUMX( 
        VALUES( 'Table'[Claim_Number] ), 
        MIN( CALCULATE( SUM( 'Table'[Total_Incurred] ) ), 2000000 ) 
    ), 
    Dates[Date] <= MAX( Dates[Date] ) 
)

 

If subtotals don't need to add up correctly (or if you want subtotals to also be capped at 2M):

 

Incurred_Capped2M_BadSubtotals = 
CALCULATE( 
    MIN( CALCULATE( SUM( 'Table'[Total_Incurred] ) ), 2000000 ),  
    Dates[Date] <= MAX( Dates[Date] ) 
)

 

In action (dates slicer is just showing end of month dates):

 

MarkLaf_0-1750286750486.gif

 

Hi @MarkLaf ,
Thank you for looking at my question. The 2M cap does not apply to sub-total and grand-total, only to the individual claims total. I edited by original request with more detailed example and what I am looking for as a result. Could you please look at it again and revise your query to help me find the solution? 

SamsonTruong
Solution Supplier
Solution Supplier

Hi @bijaymaharjan ,

Please try using the following DAX measure and let me know if it achieves your desired result:

Total Loss:=
CALCULATE (
    SUMX (
        ADDCOLUMNS(
            VALUES(Claims[Claim_Number]),
            "ClaimLoss",
                MIN(2000000, 
                      CALCULATE(
                          SUM(Claims[Total_Incurred]),
                          ALLEXCEPT (Claims, Claims[Claim_Number])
                      )
                )
        ),
        [ClaimLoss]
    ),
    USERELATIONSHIP(Claims[Policy_Eff_Date], 'Date'[Date])
)

 

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,

Samson

 

Connect with me on LinkedIn

Check out my Blog

Going to the European Microsoft Fabric Community Conference? Check out my Session

Helpful resources

Announcements
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.