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
Anonymous
Not applicable

Measure percentage of one variable based on two other columns without loosing filters

so the data I have is similar to this;

categoryvolumedatetype
a1jangroup1
a4jangroup1
b12jangroup2
c2jangroup1
b7febgroup1
a9febgroup2
c10febgroup1
c4febgroup2
b8margroup1
c3margroup1
a1margroup1
a11margroup2

 

and I have a page level filter of type; group1. I would like a graph that represents a percentage of the total per month but without loosing the filter. something like this;

 

 ABC
JAN71%0%29%
FEB0%41%59%
MAR8%67%25%
 
 
 

image.png

the best I have is;

measure=

divide(

Calculate(sum(table[volume]),allexcept(table,table[type],table[date])),

calculate(sum(table[volume]),allexcept(table,table[date])

)

 

the issue with this is that the allexcept function doesnt take into account filters.

 

can anyone help with a solution?

thanks!

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Based on your description, you can create a measure like this:

Measure = 
VAR x =
    CALCULATE (
        SUM ( 'Table'[volume] ),
        FILTER ( 'Table', 'Table'[Cal].[Month] IN DISTINCT ( 'Table'[Cal].[Month] ) )
    )
VAR xx =
    IF ( x = BLANK (), 0, x )
VAR y =
    CALCULATE (
        SUM ( 'Table'[volume] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Cal].[Month] IN DISTINCT ( 'Table'[Cal].[Month] )
        )
    )
RETURN
    DIVIDE ( xx, y )

per.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Based on your description, you can create a measure like this:

Measure = 
VAR x =
    CALCULATE (
        SUM ( 'Table'[volume] ),
        FILTER ( 'Table', 'Table'[Cal].[Month] IN DISTINCT ( 'Table'[Cal].[Month] ) )
    )
VAR xx =
    IF ( x = BLANK (), 0, x )
VAR y =
    CALCULATE (
        SUM ( 'Table'[volume] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Cal].[Month] IN DISTINCT ( 'Table'[Cal].[Month] )
        )
    )
RETURN
    DIVIDE ( xx, y )

per.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

AlB
Super User
Super User

Hi @Anonymous 

Try

Measure = DIVIDE(CALCULATE(SUM(Table1[volume])), CALCULATE(SUM(Table1[volume]), ALL(Table1[category])))

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

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
Top Kudoed Authors