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

Calculate (sub) totals in switch statement

Hi all,

 

I have created a financial statement in Power BI based on this method: 

https://www.youtube.com/watch?v=J4317R5BvsA


I have thus created many CALCULATE measures and have used the SWITCH measure to insert these in the required order.

However, I would really like to have the subtotals and gran total calculated "inside" this table, and not calculating it separately and inserting it with SWITCH, primarily to make sure there are no mistakes in the many measures that have been created manually.

In excel, the totals are shown with a simple SUM formula. Is it possible to do something in DAX?

 

Screenshots for reference:

Part of my financial statement/table below. Yellow is where I would like the subtotal, red is what should be included in this subtotal.

evabgc_0-1682566535376.png

Snippet of my SWITCH measure:

evabgc_1-1682566614057.png


Thanks in advance!

 

1 REPLY 1
lbendlin
Super User
Super User

 provide a parent hierarchy according to the groupings you want, and then use HASONEVALUE and ISINSCOPE to figure out where in the hierarchy you are.

 

Note:  Including subtotals without clear visual separation is a UX red flag.

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.

Top Solution Authors