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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
scabral
Helper IV
Helper IV

Summing a calculated column using Naturalinnerjoin not working

Hi,

 

i created 2 table variables in a DAX measure with the same column names and took care of any data lineage issues.  I can join the 2 tables correctly using NATURALINNERJOIN.  I also used Addcolumns to create a new calculated column that subtracts 2 original columns from the inner join and that works correctly as well.

 

What I'm having issues with is summing the calculated column from the joined table variable.  I would have thought it was easy, but i keep getting some really large number that doesn't make sense.

 

Here is my query so far (I am filtering the table variables to just 1 claim id for now):

 

VAR GrossClaimsReserve =
    SELECTCOLUMNS (
        CALCULATETABLE (
            ADDCOLUMNS (
                SUMMARIZE (
                    'Claim Reserve Values',
                    'Claim Reserve Values'[Claim ID],
                    'Claim Reserve Values'[LocationKey],
                    'Claim Reserve'[Reserve Peril ID],
                    'Claim Damage'[Damage Coverage Category Description]
                ),
                "Gross Claims Reserve USD", [Gross Claims Reserve USD]
            ),
            'Claim Adjustment File'[Claim Number] = "469357"
        ),
        "Claim ID", [Claim ID] + 0,
        "LocationKey", [LocationKey] + 0,
        "Peril ID", [Reserve Peril ID] + 0,
        "Damage Coverage Category Descrition", [Damage Coverage Category Description] & "",
        "Gross Claims Reserve", [Gross Claims Reserve]
    )
VAR Reinsurance =
    SELECTCOLUMNS (
        CALCULATETABLE (
            ADDCOLUMNS (
                SUMMARIZE (
                    'Claim Reinsurance Values',
                    'Claim Reinsurance Values'[Claim ID],
                    'Claim Reinsurance Values'[LocationKey],
                    'Claim Reinsurance Values'[Peril ID],
                    'Claim Damage'[Damage Coverage Category Description]
                ),
                "Gross Reinsurance USD", CALCULATE ( SUM ( 'Claim Reinsurance Values'[Reinsurance Amount USD] ) )
            ),
            'Claim Adjustment File'[Claim Number] = "469357"
        ),
        "Claim ID", [Claim ID] + 0,
        "LocationKey", [LocationKey] + 0,
        "Peril ID", [Peril ID] + 0,
        "Damage Coverage Category Descrition", [Damage Coverage Category Description] & "",
        "Gross Reinsurance USD", [Gross Reinsurance USD]
    )
VAR TableJoin =
SUMX(
    ADDCOLUMNS (
        NATURALINNERJOIN ( GrossClaimsReserve, Reinsurance ),
        "Net Net Reserve USD", [Gross Claims Reserve] - [Gross Reinsurance USD]
    ),
    [Net Net Claims Reserve USD])

 

my issue is that in the VAR TableJoin the SUMX gives me some really large number that i don't understand how it's computing it.  Here are the values in the TableJoin Variable before the SUMX ([Net Net Reserve USD] is add using the ADDCOLUMNS):

 

TableJoin (002).PNG

The SUMX should just be summing the [Net Net Reserve USD] column and i should get -48,627,000.  But instead it gives me 

82,087,844,992.0295

 and i have no idea why?

 

thanks

Scott

1 ACCEPTED SOLUTION
edhans
Super User
Super User

All the +0 does is take care of blanks. Using COALESCE(expression, 0) does the same. 

That doesn't fix data lineage. Data Lineage is a pretty deep topic. Good intro to it here

You can try this for your last variable though:

MeasureName =
SUMX(
    NATURALINNERJOIN(
        GrossClaimsReserve,
        Reinsurance
    ),
    [Gross Claims Reserve] - [Gross Reinsurance USD]
)

I don't see the need for that last ADDCOLUMNS. I'm not saying my suggestion will fix it, but it won't destroy any data lineage to this point. Without data though, it is really hard to say. I am not so good at DAX as to be able to visualized all of the tables you are creating in memory and how they flow through.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

5 REPLIES 5
edhans
Super User
Super User

Excellent @scabral - glad my "shot in the dark" worked there. 😁



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Super User
Super User

All the +0 does is take care of blanks. Using COALESCE(expression, 0) does the same. 

That doesn't fix data lineage. Data Lineage is a pretty deep topic. Good intro to it here

You can try this for your last variable though:

MeasureName =
SUMX(
    NATURALINNERJOIN(
        GrossClaimsReserve,
        Reinsurance
    ),
    [Gross Claims Reserve] - [Gross Reinsurance USD]
)

I don't see the need for that last ADDCOLUMNS. I'm not saying my suggestion will fix it, but it won't destroy any data lineage to this point. Without data though, it is really hard to say. I am not so good at DAX as to be able to visualized all of the tables you are creating in memory and how they flow through.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Yes, that sumx worked when removing ADDCOLUMNS.  

edhans
Super User
Super User

When you say you took care of data lineage, how? ADDCOLUMNS does not preserve data lineage. See ADDCOLUMNS – DAX Guide for more info, in addition to the other articles referenced from that page - specifically using GENERATE and ROW instead of ADDCOLUMNS and SUMMARIZE - Using GENERATE and ROW instead of ADDCOLUMNS in DAX - SQLBI. Depending on how this is working in your visuals, you may be able to use SUMMARIZECOLUMNS(), though that cannot evaluate filter context, but it is a great query function.




Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hi edhans,

 

i had to add the + 0 to the end of the SelectColumns for the table variables in order for the NaturalInnerJoin to work correctly.  So the 2 table variables in my code (GrossClaimsReserve and Reinsurance) are joined together correctly and the ADDCOLUMNS in the TableJoin variables adds the new column correctly as well.  What doesn't work is doing a SUMX on the new column, it gives me some really odd number that is way too large

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.