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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
SeungLee95
Microsoft Employee
Microsoft Employee

Apply SUM Total to a Conditionally Formatted Column

I have the following column in my table called SR that has the following values:

Null / 1 

 

As seen on the table below, within the Matrix it'll calculate the Subtotal for each row based on the which row level it is being displayed.

SeungLee95_0-1744064066271.png

 

 

 

 

The issue is that I created the following Measure with a dynamic format since those rows with type == Classic should show N/A for ease of data consumption while reflecting the SR value:

Measure:

TEST = IF (
    SELECTEDVALUE (COUDashboard[APType]) = "Classic",
    "N/A",
    SELECTEDVALUE(COUDashboard[ServiceReadiness])
)

 

Format:

IF ( SELECTEDVALUE ( COUDashboard[APType] ) <> "Classic", "#,0" )

 

As it can be seen in the table picture above, though, while the N/A is displayed correctly and "1" or null is as well, the subtotal isnt calculated correctly. (it should be the exact same as SR but obviously just shows "first" since I think it's calculated differently):

SeungLee95_1-1744063827170.png

 

 

SR uses SUM available

SeungLee95_2-1744058462012.png

 

Test does not have it as it is dynamically formatted ("N/A" string or numeric value)

SeungLee95_1-1744058455731.png

 

 

Is there any way to achieve a SUM subtotal done correctly for a dynamically formatted measure? Or is this not possible in Power BI?

 

I've tried creating a new column/measure with the following but it has not really worked 

TEST =
IF(
selectedvalue(coudashboard[APType]) = "Classic",
Blank(),
selectedvalue(coudashboard[Servicereadiness])
)

 

Expected Result:

I can't really show the Matrix here, but for Stamp "XXXX..." the TEST would show N/A as it is of APType == Classic

While Stamp "YYYYY-..." and the rows under it, would all have "1" as their value until it adds up to 13

StampAPTypeTEST
XXXXX-XXXXXXXClassicN/A
YYYYY-YYYYYYYConverged13
YYYYY2-YYYYYY2 (more value below)Converged7
YYYYY3-YYYYYY3 (more value below)Converged6

Thank you very much!

1 ACCEPTED SOLUTION

lbendlin_0-1744068032667.png

Test Sum =
var s = SUMX(ADDCOLUMNS('Table',"s",if([APType]="Classic",0,VALUE([TEST]))),[s])
RETURN if(s=0,"N/A",FORMAT(s,"#"))

View solution in original post

8 REPLIES 8
lbendlin
Super User
Super User

the screenshots are too small.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Hi @lbendlin - Thank you for the note, I did not notice that the images were too small when I was creating it. Apologies for that.

 

I've tried adding a table of what I mean but since I'm dealing with a Matrix the screenshots felt like it was the best way to explain while adding the queries in it.

 

I refrained from uploading the pbix file or any other queries, since the point is to avoid sensitive data as you advised.

 

Please let me know if this helps or if there's some other way I could help provide more information.

You cannot mix text and numbers in your output unless you format your numbers as text too.

Thank you @lbendlin,

 

And in that case if the numbers were text too then the SUM wouldn't be possible anyways since it's of text format right?

 

Appreciate the clarification/confirmation on this.

you can still do your math to arrive at the totals but the output format of that math needs to be text.

@lbendlin - May I ask how/what you mean on how to achieve that?

 

I don't think there'd be any issue if the output format was changed if it was consistent (for every row/level that it's showing for)

lbendlin_0-1744068032667.png

Test Sum =
var s = SUMX(ADDCOLUMNS('Table',"s",if([APType]="Classic",0,VALUE([TEST]))),[s])
RETURN if(s=0,"N/A",FORMAT(s,"#"))

Thank you @lbendlin ,

 

I was able to modify that query:

TESTSum = 

VAR hasClassic = COUNTROWS(FILTER('COUDashboard', [APType] = "Classic")) > 0
VAR s = SUMX(FILTER('COUDashboard', [APType] <> "Classic"), VALUE([ServiceReadiness]))
RETURN IF(hasClassic, "N/A", FORMAT(s, "#"))

 

And I'm now seeing the TESTSum added correctly (reflects SR values) while also showing "N/A" on Classic Capacity.

The issue I had with the original proposed query was that some columns had a 0/null by default even if their [APType] wasn't "Classic" so it was showing N/A and sums combined for other types too.

Using your query I was able to just modify it a bit and achieve exactly what I was looking for.

SeungLee95_1-1744070141153.png

 

Thank you very much!

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.