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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
rajasekar_o
Helper V
Helper V

sub total calculation

hi team , i need help ,
need to calculate sub total , i give the data and expected output
rajasekar_o_0-1706680386796.png

output

rajasekar_o_1-1706680441708.png

i try but it gives cumulative total only 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @rajasekar_o 

I'm happy to answer your questions. We can find the subtotal in the following two ways:

We can use measure to achieve the effect of finding subtotals:

Sample data:

vjianpengmsft_0-1706865544915.png

DAX formula is as follows:

 

 

 

Total A.revenue = CALCULATE(SUM(Sheet5[Amt]),'Sheet5'[item] IN {"Revanue from opration","Other"})
Total B.cost = CALCULATE(SUM(Sheet5[Amt]),'Sheet5'[item] IN {"Cost of meirial","Purchase"})

 

 

 

We can use cards to reflect the effect:

vjianpengmsft_1-1706865603232.png

 

 

Method 2, we can find the subtotal in power query:

First copy our table:

vjianpengmsft_2-1706865603235.png

 

Remove first column:

vjianpengmsft_0-1706865713081.png

pivot column:

vjianpengmsft_1-1706865741969.png

Add custom columns:

vjianpengmsft_2-1706865773306.png

vjianpengmsft_3-1706865783515.png

replace null value:

vjianpengmsft_4-1706865824388.png

Next, we unpivot the column:

vjianpengmsft_1-1706865891843.png

vjianpengmsft_2-1706865909603.png

Then we replace the value:

 

vjianpengmsft_3-1706865942609.png

 

Finally we add the index column and rename it and move it to the first column:

 

 

vjianpengmsft_5-1706865942614.png

 

Close power query and apply. I have provided my PBIX file below. If this helps you, that would be great

 

 

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

3 REPLIES 3
Anonymous
Not applicable

Hi, @rajasekar_o 

I'm happy to answer your questions. We can find the subtotal in the following two ways:

We can use measure to achieve the effect of finding subtotals:

Sample data:

vjianpengmsft_0-1706865544915.png

DAX formula is as follows:

 

 

 

Total A.revenue = CALCULATE(SUM(Sheet5[Amt]),'Sheet5'[item] IN {"Revanue from opration","Other"})
Total B.cost = CALCULATE(SUM(Sheet5[Amt]),'Sheet5'[item] IN {"Cost of meirial","Purchase"})

 

 

 

We can use cards to reflect the effect:

vjianpengmsft_1-1706865603232.png

 

 

Method 2, we can find the subtotal in power query:

First copy our table:

vjianpengmsft_2-1706865603235.png

 

Remove first column:

vjianpengmsft_0-1706865713081.png

pivot column:

vjianpengmsft_1-1706865741969.png

Add custom columns:

vjianpengmsft_2-1706865773306.png

vjianpengmsft_3-1706865783515.png

replace null value:

vjianpengmsft_4-1706865824388.png

Next, we unpivot the column:

vjianpengmsft_1-1706865891843.png

vjianpengmsft_2-1706865909603.png

Then we replace the value:

 

vjianpengmsft_3-1706865942609.png

 

Finally we add the index column and rename it and move it to the first column:

 

 

vjianpengmsft_5-1706865942614.png

 

Close power query and apply. I have provided my PBIX file below. If this helps you, that would be great

 

 

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

PijushRoy
Community Champion
Community Champion

Hi @rajasekar_o 

In your table, create a calculated column 

Category = 
SWITCH(
TRUE(),
'TableName'[Column] IN {"Revenue from operation","Other Income"},"A.Revenue",
'TableName'[Column] IN {"Cost of material","Purchase"},"B.Expense")

 

use the column in 1st level row header in Matrix visual

If not work, please share sample of your exisiting data format, relationship

If solved, please mark as SOLUTION




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





s.no

 Amt 
1A.REVANUE  
2Revanue from opration 9000 
3Other Income2000 
4B.EXPENCE   
5Cost of metirial 30000 
6purchase 35000 

calculate total for A. REVENUE AND B.EXPENCE

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.