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

View all the Fabric Data Days sessions on demand. View schedule

Reply
eyankovsky
New Member

"Difference" aggregation: how to eliminate "Total" but keep "Sum" aggregation?

I have a data set with indivudal records and group variable indicating weather each of the records belong to "Treatment" or "Control" group.

My client wants 1) to see the difference between the "Treatment" and "Control" group totals in the table and 2) "Difference" instead of "Total" in summary row.

 

Since there is no "Difference" aggregation out-of-box, I am trying to go around and  solve the issue partially by:

1)  multiply all records associated with "Treatment" group by +1 and call it "Variable (revised)"

2)  multiply all records associated with "Control" group by -1 and call it "Variable (revised)"

3) report "Variable (revised)" in a table with Group variable having "Treatment" or "Control" values

4) keep deafult "Sum" aggergation for "Variable (revised)"

 

However, the client will still see "Total" in the table summary row.

 

Is there any better way to adress client's request?

 

8 REPLIES 8
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @eyankovsky,

I am not familar your business data, I am unable to reproduce your scenario based on your description. Could you please share some sample data for further analysis? If you data is privacy, you's better create sample data and list the expected result.

 

Best Regards,
Angelia

 

Hi Angelia,
See a sample of my data below.
Thank you,
Eugene

 

aggregate_effect_in_count aggregate_effect_in_amount main_effect_in_count secondary_effect_in_count main_effect_in_amount seconadry_effect_in_amount main_effect_in_AOD_limit time Group
2 $5,679 0 1 $0 $5,679 $0 Oct-16 Treatment group
2 $11,347 0 1 $0 $11,347 $0 Sep-16 Treatment group
2 $24,942 0 1 $0 $24,942 $0 Oct-16 Treatment group
0 $0 0 0 $0 $0 $0 Sep-16 Treatment group
0 $0 0 0 $0 $0 $0 Sep-16 Control group
0 $0 0 0 $0 $0 $0 Oct-16 Control group
0 $0 0 0 $0 $0 $0 Oct-16 Control group
2 $25,142 1 1 $23,769 $1,373 $0 Sep-16 Control group

Hi @eyankovsky,

Thanks for your detail description, there eight the coulmn headers in your given sample data, while there are nine columns' data. Which is inconsistent.

 

Best Regards,
Angelia

Hi Angelia,

Below I am providing my sample again:

9 variables with Group (character variable) taking values either 'Treatment group' or 'Control group'.

 

Regards,

Eugene

 

 

 

aggregate_effect_in_countaggregate_effect_in_amountmain_effect_in_countsecondary_effect_in_countmain_effect_in_amountseconadry_effect_in_amountmain_effect_in_AOD_limittimeGroup
2$5,67901$0$5,679$0Oct-16Treatment group
2$11,34701$0$11,347$0Sep-16Treatment group
2$24,94201$0$24,942$0Oct-16Treatment group
0$000$0$0$0Sep-16Treatment group
0$000$0$0$0Sep-16Control group
0$000$0$0$0Oct-16Control group
0$000$0$0$0Oct-16Control group
2$25,14211$23,769$1,373$0Sep-16Control group

Hi @eyankovsky

Based on my understanding, I try to reproduce as follows.

 

Create three measures using the formulas.

 

Treatment = CALCULATE(SUM(Table8[seconadry_effect_in_amount]),FILTER(Table8,Table8[Group]="Treatment group"))

Control = CALCULATE(SUM(Table8[seconadry_effect_in_amount]),FILTER(Table8,Table8[Group]="Control group")) 

Diff = CALCULATE(ABS(Table8[Treatment]-Table8[Control]),ALL(Table8))


Create a table, select the "Group" field and other three measures as value level, please see the screenshot below.

 

1.PNG
If this is not what you want, could you please list your expected result? Thanks a lot.

 

Best Regards,
Angelia

Hi Angelia,

Your approach is certainly a way around to resolve the challenge.

The problme is  I have about 8 indicators in my example that my business client want to see

a) in one table, not in 8 seperate tables;

b) "Total" should be changed for Differene.

See his expected view below.

 

 

Thank you,

Eugene

GroupIndicator 1Indicator 2Indicator 3Indicator 4Indicator 5Indicator 6Indicator 7Indicator 8
Treatment group10500123002899103896588.55615.14641.73668.3
Control group10400126002900102006450542043903360
Difference100-300-1189138.5195.1251.7308.3

hi @eyankovsky

 

how are you?. Ok, let me present you an alternative solution to your problem:

 

Step 1: Create a table

 

Rows.png

 

Step 2: Related to your Main Table (Group With RowName)

 

Related.png

 

Step 3: Create this measure for Agreggate_efect-in Amount

 

Aggregate_effect_in_amount-Measure =
VAR Aggregate_effect_in_amount =
    CALCULATE ( SUM ( Table1[aggregate_effect_in_amount] ) )
VAR Aggregate_effect_in_amount_treatment =
    CALCULATE (
        SUM ( Table1[aggregate_effect_in_amount] ),
        FILTER ( ALL ( Table1 ), Table1[Group] = "Treatment Group" )
    )
VAR Aggregate_effect_in_amount_control =
    CALCULATE (
        SUM ( Table1[aggregate_effect_in_amount] ),
        FILTER ( ALL ( Table1 ), Table1[Group] = "Control Group" )
    )
RETURN
    IF (
        HASONEVALUE ( RowNames[RowName] ),
        IF (
            VALUES ( RowNames[RowName] ) = "Difference",
            Aggregate_effect_in_amount_treatment - Aggregate_effect_in_amount_control,
            Aggregate_effect_in_amount
        ),
        Aggregate_effect_in_amount
    )

Step 4: Insert a table Visual

 

table.png

 

 

 

If you don't want see totals

 

Put totals in Off

 

totalsoff.png

 

5. Repeat Step 3 to create the other measures for other indicators.

 

Ready.

 

 

 




Lima - Peru

 Hi @eyankovsky,

 

In my solution above, the difference is located in column. We are unable to transfer it to row level as your expected view. I will try to reproduce and find other way, I will post the update if there is new solution.

 

Best Regards,
Angelia

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors