Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hello,
I'm trying to create a dynamic visual that will allow me to show total count and percentantage of monthly total per subset per month, with both "percent or grand total" and the specific subset being selectable using a field parameter. It all works fine for total counts, but I'm having trouble calculating the percentage and getting the denominator to reference only the monthly total and not the grand total.
I can get it to work through brute forcing using selectedvalue() and a switch statement for the denominator where it calculates the countrows with different removefilter() statements depending on which field parameter value is selected (below), but that feels very clunky and also difficult to upkeep if the end users end up wanting more fields added to the list of allowable legends.
I've also tried using allexcept(), but then it ends up not functioning properly if it's being filtered by anything else on the page. The x axis is a date hierarchy on a date field on the same table.
Any advice would be greatly appreciated!
Percent of Quotes =
var field = SELECTEDVALUE(Legend[Legend Fields])
var fieldname = switch(true(),
CONTAINSSTRING(field,"Subset1"),"Subset1",
CONTAINSSTRING(field,"Subset2"),"Subset2",
CONTAINSSTRING(field,"Subset3"),"Subset3",
CONTAINSSTRING(field,"Subset4"),"Subset4")
var num =
countrows('Table')
var denom =
switch(fieldname,
"Subset1",
CALCULATE(
countrows(
'Table'),
REMOVEFILTERS(
'Table'[Subset1]
)
),
"Subset2",
CALCULATE(
countrows(
'Table'),
REMOVEFILTERS(
'Table'[Subset2]
)
),
"Subset3",
CALCULATE(
countrows(
'Table'),
REMOVEFILTERS(
'Table'[Subset3]
)
),
"Subset4",
CALCULATE(
countrows(
'Table'),
REMOVEFILTERS(
'Table'[Subset4]
)
)
)
return divide(num,denom,0)
Hi @jimboslice ,
Any update on this? 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
HI @jimboslice,
Perhaps you can take a look the following document about field parameter if it suitable for your requirement:
Use report readers to change visuals (preview) - Power BI | Microsoft Learn
Regards,
Xiaoxin Sheng
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
85 | |
78 | |
53 | |
38 | |
36 |
User | Count |
---|---|
100 | |
85 | |
47 | |
45 | |
44 |