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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
raphazzz
Helper I
Helper I

[HELP] Matrix with Actual Sales + Forecasted Sales showing the wrong aggregation.

Team,

I'm creating a matrix to sum the sales to date and forecasted sales.

The table rows are correct but the aggregation is wrong. I couldn't figure out what I am missing in the code.

The current month is not actual because the month is not over (for June), it's an estimated month-end (which is different than the forecasted).

Apr - Actual Sales
May - Actual Sales
June - Estimate Month-End (which is based on current sales)
July - Forecasted at the beginning of the year
August - Forecasted at the beginning of the year
September- Forecasted at the beginning of the year

 

raphazzz_1-1687073860296.png

 

The total should be $199,583,804

 

 

zCombined Actual and Forecast2 = 
VAR LastActualSaleDate =
    CALCULATE ( MAX ( SalesReport[Date Sold] ), REMOVEFILTERS () )
VAR Actuals =
    IF (
        MAX ( SalesReport[Date Sold] ) = LastActualSaleDate,
        SalesReport[zEstimate IRCV],
        SalesReport[zAct. IRCV]
    )
VAR Future =
    CALCULATE (
        SUM ( 'Sales Projection 2023'[IRCV] ),
        FILTER ( 'a.Date Table', 'a.Date Table'[Date] > LastActualSaleDate )
    )

RETURN
   Future + Actuals

 


I have no idea what might be wrong. 

4 REPLIES 4
rbriga
Impactful Individual
Impactful Individual

My DAX formula wasn't correct.

Try a hybrid- your formula (which works) within the context of a SUMX:

zCombined Actual and Forecast2 = 
VAR LastActualSaleDate =
    CALCULATE ( MAX ( SalesReport[Date Sold] ), REMOVEFILTERS () )
SUMX(
	VALUES('a.Date Table'[Year-Month]),
VAR Actuals =
    IF (
        MAX ( SalesReport[Date Sold] ) = LastActualSaleDate,
        SalesReport[zEstimate IRCV],
        SalesReport[zAct. IRCV]
    )
VAR Future =
    CALCULATE (
        SUM ( 'Sales Projection 2023'[IRCV] ),
        FILTER ( 'a.Date Table', 'a.Date Table'[Date] > LastActualSaleDate )
    )

RETURN
   Future + Actuals
)

 

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!
rbriga
Impactful Individual
Impactful Individual

Whenever indivisual values are correct and the aggragation is wrong, try an itirative function such as SUMX.

Try this (after adjustment):

zCombined Actual and Forecast2 = 
VAR LastActualSaleDate =
    CALCULATE ( MAX ( SalesReport[Date Sold] ), REMOVEFILTERS () )
SUMX(
	VALUES('a.Date Table'[Year-Month]),
	SWITCH(
		TRUE(),
		SalesReport[Date Sold]  < LastActualSaleDate, [zAct. IRCV],
		SesReport[Date Sold]  = LastActualSaleDate, SalesReport[zEstimate IRCV],
		SalesReport[Date Sold]  > LastActualSaleDate, SUM ( 'Sales Projection 2023'[IRCV] ),
		BLANK()
		)
	)

 

-------------------------
Data analyst by day, hockey goalie by night.
Did I help? Then please hit that "kudos" or "accept as a solution" button!

It didn't work, when I use SUMX is now changing the values of the rows too. 

up

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.