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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
v-xinruzhu-msft
Community Support
Community Support

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
v-xinruzhu-msft
Community Support
Community Support

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.