- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to calculate subtotal correctly with hierarchies
Hi
I am struggling with the following problem. I have a fact table in which I already receive calculated values per category and subcategory in one table. The totals per category and subcategory do not and should not be equal.
Let's assume we have category A, which is divided into 3 subcategories: AA, AB, AC. The entire category A is supposed to have a subtotal of 370, and the subcategory AA is 50, AB 100 and AC 200. The sum of the subcategories is 350, but I would not like to see 350, but 370.
I already receive the calculated data from the backend layer:
Since I have one column with values that simultaneously contains the sum of the entire category and the subcategory values, the whole thing is duplicated in the sums. How can I approach this differently?
This is an example, the real case has a category and a tree with 8 levels of subcategories, so it is very important for me that the solution is calculated correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Asmoday1507 ,
Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.
If these also don't help, please share more detailed information and description to help us clarify your scenario to test.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
If this post helps, please consider accept as solution to help other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Asmoday1507
your table is already structured as a matrix. Just put it in a table visual and will display as a matrix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can use ISINSCOPE to change the calculation logic depeding on the level of the visualization. E.g.
This will give the sum of subcategory A in total level an in the subcategory level the values are shown as normal.
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, Isinscope dax function is useful, but I don't want to see value from A in my table, value for A is only calculated subtotal in backend.
Also it's only an example, real scenario has a tree with 8 subcategories, 8 subsubcategories etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI @Asmoday1507,
Did you mean to calculate with category fields but not really use this in the visual axis?
If that is the case, you may need to add variable in measure to restore the current category group and calculate correspond result.
All the secrets of SUMMARIZE - SQLBI
Then you can lookup above variable table and filter records based on current row contexts.
Regards,
Xiaoxin Sheng
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
08-25-2024 08:26 AM | |||
06-11-2024 08:50 AM | |||
09-27-2024 05:56 AM | |||
Anonymous
| 10-09-2024 11:22 PM | ||
07-31-2024 12:23 PM |
User | Count |
---|---|
24 | |
15 | |
9 | |
9 | |
8 |
User | Count |
---|---|
19 | |
15 | |
14 | |
13 | |
13 |