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
ajimenez
Frequent Visitor

Bad behavior dax subtotal

i everyone,
I am trying to calculate the total for the field result of the following table:

YearQuarterLineTotal DaysAverage DaysTotal Items% EffectivenessResult
20163ACA12812810.056,4
20163HIL101650860.3152,4
20163INV1989994,5100.5497,25
20163TEJ52826430.1539,6
Grand Total  3661473,625201473,625

 

 

The right value I expect is 695.65.

But DAX is not adding the fields (6.4 + 152.4 + 497.25 + 39.6), instead it is multiplying the total fields Average Days (473,625) and [% Effectiveness] (1) .  I created the following Measures to perform this calculation:

Average Days = AVERAGE(Table[Total Days])
% Effectiveness = SUM(Table[Total Items]) / CALCULATE(SUM(Table[Total Items]),ALLSELECTED(Table))
Result = Table[Average Days] * Table[% Effectiveness]

 

I appreciated your help.

1 ACCEPTED SOLUTION

@ajimenez

 

Hi, Try with this DAX

 

Result =
SUMX (
    SUMMARIZE (
        Table1;
        Table1[Line];
        "RESULTS"; [AverageDays] * [% Effectiveness]
    );
    [RESULTS]
)

Review Your Column in Summarize accord to your visual & Structure.

 

S.png




Lima - Peru

View solution in original post

3 REPLIES 3
OpenDataLab
Helper II
Helper II

You need to use SUMX(table,[Result]).

 

The functions ending in X are iterator, which in lay-mans terms means they will loop through the rows in the current filter context calculating the result for each row before performing the final aggregation.

 

Thanks for your answer, but using SUMX is the same behavior, the real problem is that it applies the calculation even in the totals, it only adds the previous records only when they come from a defined table or column, not measures, because this applies the calculation for each row.

 

ItemAverage Days% EffectivenessResult with DAX
1128                   0,05128 * 0,05     = 6,4
2508                   0,30508 * 0,30     = 152,4
3994,5                   0,50994,5 * 0,50 = 497,25
4264                   0,15264 * 0,15    = 39,6
Grand Total473,625                      1473,625 * 1  = 473,625

Result = Table[Average Days] * Table[% Effectiveness]

 

I need another way to calculate this Result and being able to get the right value: 695,65

 

Thanks!!

@ajimenez

 

Hi, Try with this DAX

 

Result =
SUMX (
    SUMMARIZE (
        Table1;
        Table1[Line];
        "RESULTS"; [AverageDays] * [% Effectiveness]
    );
    [RESULTS]
)

Review Your Column in Summarize accord to your visual & Structure.

 

S.png




Lima - Peru

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.