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

Show Total/Subtotal as difference between 2 Rows

I've been asked this question by one of our reporting analysts and I can't seem to find anything online that gives me what i require.

 

Is there a way to show the bottom Row/Total/Subtotal of a table to show the difference between 2 rows? We've got the below table that shows the values of multiple measures for 2 locations. Is there a simple way of getting a final row to show the difference between each measure?

 

jackcoxer_0-1676382300259.png

In excel, it would be a simple case of having =A1/A2 in the cells below the table as below - is there a way to get this within Power BI?

jackcoxer_1-1676382392633.png

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jackcoxer 

You can refer to the following example

Sample data 

vxinruzhumsft_0-1676516806060.png

1.create a table.

Table 2 = var a=SELECTCOLUMNS({"Centre","Mobile","Key Gap"},"RowType",[Value])
var b=SELECTCOLUMNS({"Appt Time","Appt Location"},"ColumnType",[Value])
return GENERATE(a,b)

vxinruzhumsft_1-1676516851834.png

 

2.the measures are used.

Measure 2 = DIVIDE(COUNTROWS(FILTER('Table (3)',[Type]=MAX('Table 2'[RowType]))),COUNTROWS(ALL('Table (3)')))

Measure 3 = DIVIDE(SUMX(FILTER(ALL('Table (3)'),[Type]=MAX('Table 2'[RowType])),[Time]),SUMX(ALL('Table (3)'),[Time]))

3.Then create a measure to use switch() function to judge.

Measure = SWITCH(TRUE(),MAX('Table 2'[RowType])<>"Key Gap"&&MAX('Table 2'[ColumnType])="Appt Location",[Measure 2],MAX('Table 2'[ColumnType])="Appt Time"&&MAX('Table 2'[RowType])<>"Key Gap",[Measure 3],MAX('Table 2'[RowType])="Key Gap"&&MAX('Table 2'[ColumnType])="Appt Location",CALCULATE([Measure 2],'Table 2'[RowType]="Centre")-CALCULATE([Measure 2],'Table 2'[RowType]="Mobile"),MAX('Table 2'[RowType])="Key Gap"&&MAX('Table 2'[ColumnType])="Appt Time",CALCULATE([Measure 3],'Table 2'[RowType]="Centre")-CALCULATE([Measure 3],'Table 2'[RowType]="Mobile"))

Put the columns of table2 to a matrix visual and put the measure to the value field

vxinruzhumsft_2-1676517034332.png

vxinruzhumsft_3-1676517042828.png

The information above just a sample for you to offer, you can consider that use switch() function in a measure .

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @jackcoxer 

You can refer to the following example

Sample data 

vxinruzhumsft_0-1676516806060.png

1.create a table.

Table 2 = var a=SELECTCOLUMNS({"Centre","Mobile","Key Gap"},"RowType",[Value])
var b=SELECTCOLUMNS({"Appt Time","Appt Location"},"ColumnType",[Value])
return GENERATE(a,b)

vxinruzhumsft_1-1676516851834.png

 

2.the measures are used.

Measure 2 = DIVIDE(COUNTROWS(FILTER('Table (3)',[Type]=MAX('Table 2'[RowType]))),COUNTROWS(ALL('Table (3)')))

Measure 3 = DIVIDE(SUMX(FILTER(ALL('Table (3)'),[Type]=MAX('Table 2'[RowType])),[Time]),SUMX(ALL('Table (3)'),[Time]))

3.Then create a measure to use switch() function to judge.

Measure = SWITCH(TRUE(),MAX('Table 2'[RowType])<>"Key Gap"&&MAX('Table 2'[ColumnType])="Appt Location",[Measure 2],MAX('Table 2'[ColumnType])="Appt Time"&&MAX('Table 2'[RowType])<>"Key Gap",[Measure 3],MAX('Table 2'[RowType])="Key Gap"&&MAX('Table 2'[ColumnType])="Appt Location",CALCULATE([Measure 2],'Table 2'[RowType]="Centre")-CALCULATE([Measure 2],'Table 2'[RowType]="Mobile"),MAX('Table 2'[RowType])="Key Gap"&&MAX('Table 2'[ColumnType])="Appt Time",CALCULATE([Measure 3],'Table 2'[RowType]="Centre")-CALCULATE([Measure 3],'Table 2'[RowType]="Mobile"))

Put the columns of table2 to a matrix visual and put the measure to the value field

vxinruzhumsft_2-1676517034332.png

vxinruzhumsft_3-1676517042828.png

The information above just a sample for you to offer, you can consider that use switch() function in a measure .

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

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.