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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

SUMX AGGREGATION TOTALS WEIRD

Hi I force the summarization by column on a measure by item, the result is correct, but when I want to show the total something looks weird. 

 

Formula :

Comm Frcst Absolute Error =
IF('Measures IM'[Z Demand Item]<>0,
SUMX (
VALUES ( 'Item Area Values'[ITEM] ),
ABS('Measures IM'[Z ComFrcst Item]-'Measures IM'[Z Demand Item])
),
BLANK()
)
 
Result:
Case_subtotals.png
How I can fix this sum of totals?
 
Thanks a lot for your help.
 

 

2 ACCEPTED SOLUTIONS

Hi @Anonymous ,

if you want to have the sum of all date forecasts, you also have to iterate over them.

Try this:

 

Comm Frcst Absolute Error =
SUMX (
    'Bridge Dates',
    SUMX (
        VALUES ( 'Item Area Values'[ITEM] ),
        ABS ( [Z ComFrcst Item] - [Z Demand Item] )
    )
)

 

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


View solution in original post

Anonymous
Not applicable

Hi all,

 

I already find a way to solve:

 

Comm Frcst Absolute Error =
VAR TableAgg = SUMMARIZE('Date','Date'[Date Forecast],"Agg_Value",[Comm Frcst Absolute Error Base])
RETURN
IF(HASONEVALUE('Date'[Date Forecast]),[Comm Frcst Absolute Error Base],sumx(TableAgg,[Agg_Value]))
 
Put the result on a virtual table and then aggregate.
 
Thanks all of you for your help.
 

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi all,

 

I already find a way to solve:

 

Comm Frcst Absolute Error =
VAR TableAgg = SUMMARIZE('Date','Date'[Date Forecast],"Agg_Value",[Comm Frcst Absolute Error Base])
RETURN
IF(HASONEVALUE('Date'[Date Forecast]),[Comm Frcst Absolute Error Base],sumx(TableAgg,[Agg_Value]))
 
Put the result on a virtual table and then aggregate.
 
Thanks all of you for your help.
 

Hi @Anonymous ,

 

I think your IF statement receives a different result on the total than on the monthly level.

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Anonymous
Not applicable

Hi @mwegener , actually I try this alternative, but the result is the same.

Hi @Anonymous ,

 

could you give an overview of your data model and the other two measures?

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Anonymous
Not applicable

Hi @mwegener, yes, this is it:

 

Measures:

Z ComFrcst Item =
var Unit = CALCULATE(SUM('W_GROWTH_ITAR'[COMM_FRCST]), All(W_GROWTH_ITAR[ITEM]))
var Cost = CALCULATE(SUM('W_GROWTH_ITAR'[COMM_FRCST]), All(W_GROWTH_ITAR[ITEM]))*SUM('Item Area Values'[UNITCOST])
var Price = CALCULATE(SUM('W_GROWTH_ITAR'[COMM_FRCST]), All(W_GROWTH_ITAR[ITEM]))*SUM('Item Area Values'[LISTPRICE])
var SelectMeasure = MIN(UoM[ID])
return
if(
HASONEVALUE(UoM[Name]),
SWITCH(SelectMeasure,
1,Unit,2,Price,3,Cost))

Z Demand Item =
var Unit = CALCULATE(SUM('Demand Planning'[Demand]),ALL('Demand Planning'[Item]))
var Cost = CALCULATE(SUM('Demand Planning'[Demand]),ALL('Demand Planning'[Item]))*SUM('Item Area Values'[UNITCOST])
var Price = CALCULATE(SUM('Demand Planning'[Demand]),ALL('Demand Planning'[Item]))*SUM('Item Area Values'[LISTPRICE])
var SelectMeasure = MIN(UoM[ID])
return
if(
HASONEVALUE(UoM[Name]),
SWITCH(SelectMeasure,
1,Unit,2,Price,3,Cost))
 
Data model:
Case_subtotals_v2.png
 
In Red: Qty tables with different level of aggregation
In Orange: Comom related Table
In Green: Date Table
 
The other measures are the result of the ABS Error formula.

Hi @Anonymous ,

 

the data model and the measures look very complex. (Too complex for my taste.)

I think based on that I can hardly predict a result.

 

I would recommend a star schema and precalculations with Power Query (unit, cost, price)

https://docs.microsoft.com/en-us/power-bi/guidance/star-schema

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Anonymous
Not applicable

 

 

Measures:

Z ComFrcst Item =
CALCULATE(SUM('W_GROWTH_ITAR'[COMM_FRCST]), All(W_GROWTH_ITAR[ITEM]))

Z Demand Item =
CALCULATE(SUM('Demand Planning'[Demand]),ALL('Demand Planning'[Item]))

Then I aggregate by item to calculate this:
SUMX (
VALUES ( 'Item Area Values'[ITEM] ),
ABS('Measures IM'[Z ComFrcst Item]-'Measures IM'[Z Demand Item])
)
 
the weird thing is the grand total doesn't summarize correctly.

Thanks.

Hi @Anonymous ,

if you want to have the sum of all date forecasts, you also have to iterate over them.

Try this:

 

Comm Frcst Absolute Error =
SUMX (
    'Bridge Dates',
    SUMX (
        VALUES ( 'Item Area Values'[ITEM] ),
        ABS ( [Z ComFrcst Item] - [Z Demand Item] )
    )
)

 

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Anonymous
Not applicable

Hi @mwegener, actually works, I try it again.

 

SUMX (
VALUES ('Date'[Date Forecast]),
SUMX (
VALUES ( 'Item Area Values'[ITEM] ),
ABS ( 'Measures IM'[Z ComFrcst Item] - 'Measures IM'[Z Demand Item] )
)
 
Thanks!!
Anonymous
Not applicable

Does not work, but help me to find the way, thanks a lot @mwegener 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.