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
Anonymous
Not applicable

How to achieve multiple rows in subtotal

Hello,
I have learned Power BI for few weeks.
I want to make a report in Power BI, which should look something like this 🙂

 

michaelC0_0-1609886320959.png

Let's assume that all data comes from the Person table, and that when counting absent people, we do not distinguish whether it is a student or a teacher.
Person
(
id
, gender in (M, F)
, position in (student, teacher)
, isPresent in (1, 0)
)

Is it possible to do something like this in Power BI?
I mean whether it is possible to present the summarization in multiple rows (like on picture in few rows below TOTAL row)?
And is it possible to make two-line header in the matrix (as in my picture)?

1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi, @michaelC0

You can use following method to meet your needs:

Step1: Create a table as:

1.png

Step2: Create a measure as:

Measure =

IF(ISINSCOPE('Table'[Gender ]),SUM('Table'[Qty]),

var _total=SUMX(VALUES('Table'[Career]),SUM('Table'[Qty]))

var _totalall=SUMX(ALL('Table'),'Table'[Qty])

Return

FORMAT(DIVIDE(_total,_totalall),"percent"))

Here is the output:

2.png

Here is the demo, please try it: How to achieve multiple rows in subtotal

 

Best Regards,

Link

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

5 REPLIES 5
v-xulin-mstf
Community Support
Community Support

Hi, @michaelC0

You can use following method to meet your needs:

Step1: Create a table as:

1.png

Step2: Create a measure as:

Measure =

IF(ISINSCOPE('Table'[Gender ]),SUM('Table'[Qty]),

var _total=SUMX(VALUES('Table'[Career]),SUM('Table'[Qty]))

var _totalall=SUMX(ALL('Table'),'Table'[Qty])

Return

FORMAT(DIVIDE(_total,_totalall),"percent"))

Here is the output:

2.png

Here is the demo, please try it: How to achieve multiple rows in subtotal

 

Best Regards,

Link

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

Anonymous
Not applicable

v-xulin-mstf  , thank you. Your answer helped me a lot.

Now I am trying to calculate percentage (not sum) within each group.

 

Przykład3.jpg

Then I could eventually make a report that will consist of two matrixes - first with subtotals for each groups and second with grand total.

Anonymous
Not applicable

Thank you for your response.

Is there a possibility to achieve at least somethink like that:

michaelC0_0-1610056688436.png

?

 

I guess first I need to create some measures:
all_persons = COUNT(Person[id]) 
It gives 100 (44 + 43 + 5 + 6 + 1+ 1)

students = CALCULATE (DISTINCTCOUNT (Person[IsStudent]), FILTER ( Person[IsStudent]= 1))
It gives 87 (44 + 43)

teachers = CALCULATE (DISTINCTCOUNT (Person[isTeacher]), FILTER ( Person[isTeacher]= 1))
It gives 11 (5 + 6)

But how to create new measure which return proper value (students or teachers) for specific column? I mean 87 for column STUDENT and 11 for column TEACHER.
If I have such measure then I could calculate percentage.

 

In my previous post I forgot to write that I use matrix with fields group and gender in Rows and isStudent, isTeacher in Values.

Person
(
id
, gender in (M, F)

, group
, isStudent (1, 0)
, isTeacher (1, 0)
, isPresent in (1, 0)
)

amitchandak
Super User
Super User

@Anonymous , I doubt you can get a display like that easily. Check if there is some custom visual that can help

https://appsource.microsoft.com/en-us/marketplace/apps?product=power-bi-visuals

 

Another Idea can be that you create few visuals and group them together : https://docs.microsoft.com/en-us/power-bi/desktop-grouping-visuals

parry2k
Super User
Super User

@Anonymous To be very honest, it is not going to be easy to get the output the way you described. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.