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

The 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.

Reply
jimboslice
Regular Visitor

Percentage Month over Month for Dynamic Visual using Field Parameters

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)

 

 

2 REPLIES 2
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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