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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
GeorgWildmoser
Frequent Visitor

Dax Query Incorrect Total

Hi,

my DAX query is producing the correct values by line but the incorrect value for the total. 

GeorgWildmoser_0-1718363590223.png

 

I thought I could fix the total problem with sumx. But obviously I'm doing something wrong here.

 

The DAX query:

Netto (12M v.DocDate) =
// Define the maximum date in 'TimeIfDocumentElsePostingDate' table
var maxDate = MAX('TimeIfDocumentElsePostingDate'[Date Date])

// Get the current date minus one day
var aktDate = TODAY() - 1

// Determine which date to use: maxDate or the current date (aktDate)
var useDate = IF(maxDate <= aktDate, maxDate, aktDate)

// Create a table of dates within the past year from 'useDate'
var DateTbl = DATESINPERIOD('TimeIfDocumentElsePostingDate'[Date Date], useDate, -1, YEAR)

// Calculate the Intermediate List for the last 12 months (IL12M)
var IL12M =
    CALCULATETABLE(
        ADDCOLUMNS(
            // Summarize data from 'CUB_AccountsReceivable_Tax' table by certain dimensions and dates
            SUMMARIZE(
                CUB_AR,
                DIM_Dim5[Dimension5Display],
                DIM_VoucherAR[VoucherARBusinessKeySurrogate],
                TimeCloseDate[Date Date],
                TimeDueDate[Date Date]
            ),
            // Add a column for due date plus 90 days
            "@DueDatePlus90", DATEADD(TimeDueDate[Date Date], 90, DAY),
            // Add a column for the current close date, handling blanks and dates beyond 'useDate'
            "@CloseDateCur", IF(
                ISBLANK(TimeCloseDate[Date Date]) || TimeCloseDate[Date Date] > useDate,
                useDate,
                TimeCloseDate[Date Date]
            )
        ),
        DateTbl,
        // Filter where 'TimeDueDate'[TimeBusinessKeySurrogate] is not blank
        NOT ISBLANK('TimeDueDate'[TimeBusinessKeySurrogate]),
        // Filter by specific document types in 'DIM_VoucherAR'[VoucherARDocumentTypeShort]
        DIM_VoucherAR[VoucherARDocumentTypeShort] IN {"FTG", "GS", "RG", "FTR"}
    )
// Summarize the filtered table by VoucherARBusinessKeySurrogate
var VOD =
    SUMMARIZE(
        IL12M,
        DIM_VoucherAR[VoucherARBusinessKeySurrogate]
    )
// Return the sum of 'TaxBaseAmountCur' from the filtered table IL12M, applying an additional filter for specific document types
RETURN
    CALCULATE(
    SUMX(
        VOD,
        [TaxBaseAmountCur]
    ),
    DIM_VoucherAR[VoucherARDocumentTypeShort] IN {"FTG", "GS", "RG", "FTR"}
)

 

Please give me some support. Thanks a lot.

 

1 ACCEPTED SOLUTION
xifeng_L
Super User
Super User

Hi @GeorgWildmoser 

 

There is a general method to solve the problem that the total does not equal the breakdown, you can refer to it.

 

Create New Measure = 
SUMX(
    CROSSJOIN(
        VALUES('Table'[Row Field1]),
        VALUES('Table'[Row Field2]),
        VALUES('Table'[Row Field3]),
        ...
    ),
    [Old Measure]
)

 

According to your screenshot, you should fill the first 6 columns into VALUES in order.

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

View solution in original post

1 REPLY 1
xifeng_L
Super User
Super User

Hi @GeorgWildmoser 

 

There is a general method to solve the problem that the total does not equal the breakdown, you can refer to it.

 

Create New Measure = 
SUMX(
    CROSSJOIN(
        VALUES('Table'[Row Field1]),
        VALUES('Table'[Row Field2]),
        VALUES('Table'[Row Field3]),
        ...
    ),
    [Old Measure]
)

 

According to your screenshot, you should fill the first 6 columns into VALUES in order.

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.