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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
bedata1
Frequent Visitor

Matrix Total is not correct

Hi Community, 

 

Situation

I created a Matrix visual with two tables "GeneralLedgerEntries" (Actual Amount) & "Budget" (Budget Amount). 

I created the follow DAX (with Date = 2023,01,31 --> this means it should show the actual amount up to that date, from then on the budget amount):

LE = 
var SelectedDate = Date(2023,01,31)
var ActualAmount = 
CALCULATE(
    SUM(GeneralLedgerEntries[Amount]),     FILTER(GeneralLedgerEntries, GeneralLedgerEntries[Posting_Date] <= SelectedDate)
)
var BudgetAmount =    
CALCULATE(
    SUM(Budget[Amount]),
    FILTER(Budget, Budget[Date] > SelectedDate)
)
return
IF(
    MAX(Budget[Date]) > SelectedDate,
    BudgetAmount,
    ActualAmount
)

 

Problem

I would like to show the total per quarter, but unfortunately the total is not correct.
It only adds the two columns "2023.02"+"2023.03" which come from the table "Budget". However, "2023.01"+"2023.02"+"2023.03" should calculate ("2023.01" come from the table "GeneralLedgerEntries")...

bedata1_0-1681194345970.png

 

Does anyone have an idea what it could be so I can calculate the correct total?

1 ACCEPTED SOLUTION
FreemanZ
Community Champion
Community Champion

hi @bedata1 

try like:

LE =
var SelectedDate = Date(2023,01,31)
var ActualAmount =
CALCULATE(
    SUM(GeneralLedgerEntries[Amount]),     
    FILTER(GeneralLedgerEntries, GeneralLedgerEntries[Posting_Date] <= SelectedDate)
)
var BudgetAmount =    
CALCULATE(
    SUM(Budget[Amount]),
    FILTER(Budget, Budget[Date] > SelectedDate)
)
return
    BudgetAmount + ActualAmount

View solution in original post

3 REPLIES 3
bedata1
Frequent Visitor

@FreemanZ  Thank you, it works - as always, a perfect and fast help!
@tamerj1 Thank you as well for your help.

tamerj1
Community Champion
Community Champion

Hi @bedata1 
Please try

LE =
SUMX (
    VALUES ( Budget[YearMonth] ),
    VAR SelectedDate =
        DATE ( 2023, 01, 31 )
    VAR ActualAmount =
        CALCULATE (
            SUM ( GeneralLedgerEntries[Amount] ),
            FILTER (
                GeneralLedgerEntries,
                GeneralLedgerEntries[Posting_Date] <= SelectedDate
            )
        )
    VAR BudgetAmount =
        CALCULATE (
            SUM ( Budget[Amount] ),
            FILTER ( Budget, Budget[Date] > SelectedDate )
        )
    RETURN
        IF (
            CALCULATE ( MAX ( Budget[Date] ) ) > SelectedDate,
            BudgetAmount,
            ActualAmount
        )
)
FreemanZ
Community Champion
Community Champion

hi @bedata1 

try like:

LE =
var SelectedDate = Date(2023,01,31)
var ActualAmount =
CALCULATE(
    SUM(GeneralLedgerEntries[Amount]),     
    FILTER(GeneralLedgerEntries, GeneralLedgerEntries[Posting_Date] <= SelectedDate)
)
var BudgetAmount =    
CALCULATE(
    SUM(Budget[Amount]),
    FILTER(Budget, Budget[Date] > SelectedDate)
)
return
    BudgetAmount + ActualAmount

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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