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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
watje255_ju
Helper III
Helper III

SUMX not totalling correctly (as expected)/ causing error in matrix?

Hello, 

I have had a good read of the forums, but I cannot find an answer that works for me so looking for some more help please.

 

The SUMX measure is not giving the total I would expect (the sum of all the rows), which is 7,477,673 (see pivot below). I think this is throwing out the NaN values in the matrix.

 

The measure and matrix is working perfectly for company 3 however, does anyone know why? PBIX link

below https://1drv.ms/u/s!As8wMr9_bgGrgWHiaY16y4XdpEnn?e=wBkO8L

 

This @v-cazheng-msft is a follow on of your help @tamerj1   

 

Thanks for your time

watje255_ju_0-1657494234869.png

watje255_ju_1-1657494254997.png

 

watje255_ju_2-1657494390893.png

 

Test Group NZD Balances =

VAR FXTranslationDate = // set the FX translation date to the slicer reporting date
MAX ( DimDate[DateKey] )
VAR SelectedCurrencyKey = // find the currency key for the particular invoice
MAX ( FactAccountsReceivable[Currency Key] )
VAR LookedExchangeRate = // filter the currency table for the reporting date and the invoice currency
CALCULATE (
MAX ( FactExchangeRate[Exchange Rate] ),
FILTER (
FactExchangeRate,
FactExchangeRate[Valid From] = FXTranslationDate
&& FactExchangeRate[To Currency Key] = SelectedCurrencyKey
)
)
VAR ConvertFXInvoices = //exclude NZD balances from the calculation
CALCULATE ( SUMX (
FactAccountsReceivable,
FactAccountsReceivable[Amount Currency] / LookedExchangeRate),
FILTER (FactAccountsReceivable,
FactAccountsReceivable[Currency Key] <>4))

VAR Co6NZDInvoices = // filter for NZD invoices which don't need an FX translation
CALCULATE ( SUM ( FactAccountsReceivable[Amount Currency]) ,
FILTER ( FactAccountsReceivable , FactAccountsReceivable[Currency Key] =4))

Return
ConvertFXInvoices + Co6NZDInvoices
1 ACCEPTED SOLUTION

Hi,

Thank you for your feedback.

Could you please check the below picture and the attached pbix file?

 

Picture1.png

 

Measure total fix: = 
SUMX (
    SUMMARIZE (
        FactAccountsReceivable,
        FactAccountsReceivable[Voucher],
        FactAccountsReceivable[Customer Key]
    ),
    [Test Group NZD Balances]
)

 

Amount Per Bucket = 
CALCULATE (
    [Measure total fix:],
    FILTER (
        VALUES ( FactAccountsReceivable[Voucher] ),
        VAR FromDays =
            MIN ( 'Aging Groups ATB'[From] )
        VAR ToDays =
            MAX ( 'Aging Groups ATB'[To] )
        RETURN
            [Days Over 2] > FromDays
                && [Days Over 2] <= ToDays
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

6 REPLIES 6
watje255_ju
Helper III
Helper III

Working like a dream now, thank you very much @Jihwan_Kim !

Jihwan_Kim
Super User
Super User

Hi,

Please try the below measure.

Sorry that I could not fully understand your measure, however, the cause of not providing correct total might be solved by writing the below measure additionally.

 

Untitled.png

 

Measure total fix: = 
SUMX( VALUES( FactAccountsReceivable[Voucher]), [Test Group NZD Balances] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi @Jihwan_Kim 

 

Thanks so much for your reply, that works great, do you know why I am getting the NaN error for the 90+ day bucket when the just looking at the bucket level? Thanks again! 

watje255_ju_0-1657521371589.png

 

Hi,

Thank you for your message.

It is quite difficult for me to check without understanding what your DAX measures are looking for.

Could you please try the below measure and please let me know if it provides the correct outcome or not.

 

Amount Per Bucket =
SUMX (
    VALUES ( 'Aging Groups ATB'[Bucket] ),
    CALCULATE (
        [Measure total fix:],
        FILTER (
            VALUES ( FactAccountsReceivable[Voucher] ),
            VAR FromDays =
                MIN ( 'Aging Groups ATB'[From] )
            VAR ToDays =
                MAX ( 'Aging Groups ATB'[To] )
            RETURN
                [Days Over 2] > FromDays
                    && [Days Over 2] <= ToDays
        )
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi @Jihwan_Kim , thanks again for your time. I would like the Dax measure to show the correct total for for each bucket ( the individual rows are correct), the matrix with the detail is correct, you can see Age 90+ days and the total has a NaN error in the table on the right, where I would like to see the 1009, and total of 7,477k? Much appreciated!

watje255_ju_0-1657530606594.png

 

Hi,

Thank you for your feedback.

Could you please check the below picture and the attached pbix file?

 

Picture1.png

 

Measure total fix: = 
SUMX (
    SUMMARIZE (
        FactAccountsReceivable,
        FactAccountsReceivable[Voucher],
        FactAccountsReceivable[Customer Key]
    ),
    [Test Group NZD Balances]
)

 

Amount Per Bucket = 
CALCULATE (
    [Measure total fix:],
    FILTER (
        VALUES ( FactAccountsReceivable[Voucher] ),
        VAR FromDays =
            MIN ( 'Aging Groups ATB'[From] )
        VAR ToDays =
            MAX ( 'Aging Groups ATB'[To] )
        RETURN
            [Days Over 2] > FromDays
                && [Days Over 2] <= ToDays
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.