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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.