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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.

Reply
Sarutra
Helper I
Helper I

Wrong Total sum

Hello,

I can't solve the total sum issue, can you help?

Sarutra_0-1737805645141.png

 

I am attaching a link to the Power BI file

https://sarutra-my.sharepoint.com/:u:/p/powerbi/EVlVgZt4wyRMrWefGdfwqEMBN8961ITPyhT4eOEXgFwsEA?e=kUM...

 

I will be very grateful for your help in solving the problem.

 

Arturas

1 ACCEPTED SOLUTION

You are welcome.  If my previous reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

I created this measure

Measure = if(ISBLANK([Unpaid Amount]),BLANK(),SUMX(VALUES('sales-payments'[Indeksas]),[Unpaid Amount]))

Hope this helps.

Ashish_Mathur_0-1737849545758.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

Rezult blank measure

 

Arturas

 

You are welcome.  If my previous reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

In the screenshot, as you can see i get the correct result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sorry, you are right.

Do you have any ideas why the measure total is showing correctly, but the value in the row for some customers is incorrect?     

Sarutra_0-1737891865367.png

Arturas

danextian
Super User
Super User

Hi @Sarutra 

What do TRUE and NO TRUE mean? What is your expected result?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
rohit1991
Super User
Super User

Hi @Sarutra ,

Fix for Incorrect Totals in Power BI

  1. Adjust Measure Logic: Use SUMX to calculate row-by-row: Unpaid Amount = SUMX(sales-payments, sales-payments[Open Order Total] - sales-payments[Credit])

  2. Handle Totals Separately: Use ISINSCOPE to distinguish rows from totals: Unpaid Amount =
    IF(
    ISINSCOPE(sales-payments[Index]),
    sales-payments[Open Order Total] - sales-payments[Credit],
    SUM(sales-payments[Open Order Total]) - SUM(sales-payments[Credit])
    )
  3. Check Data Model: Ensure relationships are correct and no inactive ones affect the calculation. This should resolve your issue.

 

It's not that simple. I am attaching the measure formula.

 

Unpaid Amount =
VAR BalanceToPay = [Open Order Total]  -- Paskutinė neapmokėta suma

VAR RunningTotal =
    CALCULATE(
        SUM('sales-payments'[Debet]),
        FILTER(
            ALLSELECTED('sales-payments'),
            'sales-payments'[Customer code] = SELECTEDVALUE('sales-payments'[Customer code]) &&
            'sales-payments'[Indeksas] >= MAX('sales-payments'[Indeksas])
        )
    )

VAR RemainingAmount =
    IF(
        BalanceToPay - RunningTotal >= 0,
        MAX('sales-payments'[Debet]),
        IF(
            BalanceToPay - (RunningTotal - MAX('sales-payments'[Debet])) > 0,
            BalanceToPay - (RunningTotal - MAX('sales-payments'[Debet])),
            0
        )
    )

RETURN
IF(
    HASONEVALUE('sales-payments'[Invoice NR]),
    IF(RemainingAmount > 0, RemainingAmount, BLANK()),
    SUMX(
        FILTER(
            ALLSELECTED('sales-payments'),
            'sales-payments'[Customer code] = SELECTEDVALUE('sales-payments'[Customer code])
        ),
        IF(
            BalanceToPay -
            CALCULATE(
                SUM('sales-payments'[Debet]),
                FILTER(
                    ALLSELECTED('sales-payments'),
                    'sales-payments'[Customer code] = SELECTEDVALUE('sales-payments'[Customer code]) &&
                    'sales-payments'[Indeksas] >= EARLIER('sales-payments'[Indeksas])
                )
            ) >= 0,
            'sales-payments'[Debet],
            IF(
                BalanceToPay -
                CALCULATE(
                    SUM('sales-payments'[Debet]),
                    FILTER(
                        ALLSELECTED('sales-payments'),
                        'sales-payments'[Customer code] = SELECTEDVALUE('sales-payments'[Customer code]) &&
                        'sales-payments'[Indeksas] >= EARLIER('sales-payments'[Indeksas])
                    )
                ) - 'sales-payments'[Debet] > 0,
                BalanceToPay -
                CALCULATE(
                    SUM('sales-payments'[Debet]),
                    FILTER(
                        ALLSELECTED('sales-payments'),
                        'sales-payments'[Customer code] = SELECTEDVALUE('sales-payments'[Customer code]) &&
                        'sales-payments'[Indeksas] <= EARLIER('sales-payments'[Indeksas])
                    )
                ),
                0
            )
        )
    )
)

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.