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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
smpa01
Super User
Super User

Manipulation of Row Level Subtotal

@AlexisOlson @CNENFRNL @bcdobbs @parry2k 

 

I want to be able to manipulate the subtotal on a matrix visual as per the business req.

The req tells me to show fact_max as it is currently visible now but to eliminate fact_sum from row subtotals at any level

 

smpa01_0-1740775234521.png

What I tried?

 

I built a debugger like this which exposes the current level whether in scope and built a measure that listens to whether the current level is in scope.

So my debugger is like this

smpa01_2-1740776027798.png

 

and measure is like this, works pretty well on L1

smpa01_3-1740776111886.png

 

fails from L2 onwards

smpa01_4-1740776233688.png

 

How can I achieve the desired outcome?

N.B. I don't want to achieve this by matching the text color to background color

smpa01_5-1740776922897.png

 

Thank you in advance.
PFA sample

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
14 REPLIES 14
v-kathullac
Community Support
Community Support

Hi @smpa01 ,

we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.

If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

Regards,

Chaithanya.

v-kathullac
Community Support
Community Support

Hi @smpa01 ,

we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.

If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

Regards,

Chaithanya.

v-kathullac
Community Support
Community Support

Hi @smpa01 ,

we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.

If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

Regards,

Chaithanya.

AlexisOlson
Super User
Super User

It's not too hard to write a measure that works at any particular level. The problem here is that you want a measure that returns a different value at e.g. the country level depending on whether the state level is expanded or not. I suspect this may not be possible since it's essentially asking for an inconsistent definition of a measure.

 

There are possible workaround with bookmarks or maybe adding a new parameter to control what levels show up (rather than using the visual's drill up/down behavior).

 

 

I think the problem can be narrowed down to

if there is a way DAX can return which level is currently expanded in matirx, and based on that manipulate each measure. But I dont think DAX has a way to  return this info @jeffrey_wang 

debugger6 = 
VAR L1 =ISINSCOPE ( dim_L1[L_1] )
VAR L2 =ISINSCOPE ( dim_L2[L_2] )
VAR L3 =ISINSCOPE ( dim_L3[L_3] )
VAR tbl =
    SWITCH (
        TRUE (),
        L1 = TRUE () && L2 =FALSE(),
            TOJSON (
                SUMMARIZECOLUMNS (
                    ROLLUPADDISSUBTOTAL ( 'dim_L1'[L_1], "IsGrandTotalRowTotal" )
                ),
                -1
            ),
        L1 = TRUE ()
            && L2 = TRUE () && L3=FALSE(),
            TOJSON (
                SUMMARIZECOLUMNS (
                    ROLLUPADDISSUBTOTAL (
                        'dim_L1'[L_1],
                        "IsGrandTotalRowTotal",
                        'dim_L2'[L_2],
                        "IsDM1Total"
                    )
                ),
                -1
            ),
        L1 = TRUE ()
            && L2 = TRUE ()
            && L3 = TRUE (),
            TOJSON (
                SUMMARIZECOLUMNS (
                    ROLLUPADDISSUBTOTAL (
                        'dim_L1'[L_1],
                        "IsGrandTotalRowTotal",
                        'dim_L2'[L_2],
                        "IsDM1Total",
                        'dim_L3'[L_3],
                        "IsDM3Total"
                    )
                ),
                -1
            )
    )
RETURN
    tbl

 

smpa01_0-1741027042641.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

I think ISINSCOPE can handle that but you MUST start from the bottom up, not from the top down.

Starting from the bottom up, we can detect the current level

current_level =
SWITCH (
    TRUE (),
    ISINSCOPE ( dim_L3[L_3] ), 3,
    ISINSCOPE ( dim_L2[L_2] ), 2,
    ISINSCOPE ( dim_L1[L_1] ), 1,
    0
)

 

The hard part is detecting the maximum level that is displayed in the visual. If you have that, all you need is

IF ( [current_level] = [max_level], [fact_sum] )

But I can't see how to calculate [max_level] dynamically in a subtotal row filter context.

the simplistic answer would be HASONEVALUE but that can backfire badly if a parent level only has a single child.

I genuinely feel this is a problem that appears simpler than what it is. To gauge the full complexity, you need to give this a try.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Oh, I have tried, and failed, a couple of times. I am fully aware of the complexities.  In fact this is very much along the lines of the issue with field parameters.  You cannot programmatically probe in which order a report user has added field parameter values to a visual.

 

Potentially visual calculations via PARENT could be an option.

I don't think PARENT is a DAX function. I tinkered a bit with EXPAND / COLLAPSE with no success.

I don't know if VISUAL CALCULATION can handle it,

but if I assume for a minute that VISUAL CALCULATION can handle it, can it handle the DAX measure to handle pre or post evaluation.

 

If it is pre, I am interested but if post I am not. I want regular DAX/Visual Calcuation to restrict it from even evaluating on the Row Subtotal level.

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

you are right, I was thinking of COLLAPSE and COLLAPSEALL.

 

A while back Alberto had confirmed that this was a design gap

lbendlin
Super User
Super User

You need to start from the lowest level up, not from the highest level down.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.