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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Andrea_Jess
Helper III
Helper III

Incorrect Grand Total

Hi all, 

 

I have this DAX formula to basically calculate sum of amount for months after selected date. 

 

Show Future Forecast =

var a = SUM(Data[Amount])
var b = MAX(Data[Month for Finacial Date])
var c = MAX(Data[Year for Finacial Date])
RETURN
if (b <= SELECTEDVALUE(DimDate[MonthNum]) && c = SELECTEDVALUE(DimDate[Year]) , BLANK(), a)
 
This is what it returns. The Totals for Amount and the Totals for Show Future Forecast are the same but it shouldn't be since Show Future Forecast is missing two months. Is anyone able to assist and advise why?

Andrea_Jess_0-1636270793543.png

 

 

 

3 REPLIES 3
TomMartens
Super User
Super User

Hey @Andrea_Jess ,

 

Forecast and Amount are the same in the Total Line, as there is no active filter for year month in the total.

You can solve this using the table iterator function SUMX SUMX – DAX Guide.

Your measure then will be similar to this:

Show Future Forecast = 
SUMX(
    SUMMARIZE(
        '<yourcalendartable>'
        , '<yourcalendartable>'[year]
        , '<yourcalendartable>'[month]
    )
    , ... // the numeric expression
)

The numeric expression might look like this:

var a = CALCULATE( SUM(Data[Amount]) )
var b = CALCULATE( MAX(Data[Month for Finacial Date]) )
var c = CALCULATE( MAX(Data[Year for Finacial Date]) )
RETURN
if (b <= SELECTEDVALUE(DimDate[MonthNum]) && c = SELECTEDVALUE(DimDate[Year]) , BLANK(), a)

The CALCULATE is necessary to transform the existing ROW context that has been created by the table iterator function SUMX into a filter context.

 

Hopefully, this provides what you are looking for to tackle this challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom,

 

Thanks for that. That makes sense. Unfortunately, i'm still getting the same totals even with the addition of the SUMX function. This is what i'm using now. Is there something incorrect i'm doing here?

 


SUMX(
SUMMARIZE(
'DimDate'
, 'DimDate'[Year]
, 'DimDate'[Month]),

var a = CALCULATE( SUM(Data[Amount]) )
var b = CALCULATE( MAX(Data[Month for Finacial Date]) )
var c = CALCULATE( MAX(Data[Year for Finacial Date]) )
RETURN
if (b <= SELECTEDVALUE(DimDate[MonthNum]) && c = SELECTEDVALUE(DimDate[Year]) , BLANK(), a))

 

 

 

Hey @Andrea_Jess ,

 

please create a pbix file that contains sample data but still reflects your data model (tables, relationships between tables, calculated columns, and measures). Upload the pbix to onedrive or dropbox and share the link. If you are using Excel to create the sample data instead of the manual input method share the xlsx as well.
Please explain the expected result based on the sample data you provided.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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