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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
mglomb
Frequent Visitor

% Of total from data set

I have this database as per below, with product count of product and if the product is single (only one) or multiple (=>2).

 

In Excel, I can easily use the total % per role and get the information I need (as per below too), but I don't know how to that that in PBI. Can you please help?

 

Screenshot 2021-12-02 112827.jpg

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @mglomb 

 

If you use matrix visual, you can create a measure.

Like this:

Measure = 
VAR a =
    CALCULATE (
        SUM ( 'Table'[Count] )
    )
VAR b =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER (ALL( 'Table'), [Product]=SELECTEDVALUE('Table'[Product]))
    )
RETURN
 a/b
Multiple = 
VAR a =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER ( 'Table', [Single/Multiple] = "Single" )
    )
VAR b =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER ( 'Table', [Single/Multiple] = "Multiple" )
    )
RETURN
    b / ( a + b )

vjaneygmsft_1-1638958888209.png

 

 Since the values of non-existent rows can't be displayed in the matrix in powerbi, 0% can't be displayed. 

But if you use table visual, it can be displayed.

Like this:

Single = 
VAR a =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER ( 'Table', [Single/Multiple] = "Single" )
    )
VAR b =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER ( 'Table', [Single/Multiple] = "Multiple" )
    )
RETURN
    a / ( a + b )+0

vjaneygmsft_2-1638958896178.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

 

Best Regards,
Community Support Team _ Janey

View solution in original post

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi, @mglomb 

 

If you use matrix visual, you can create a measure.

Like this:

Measure = 
VAR a =
    CALCULATE (
        SUM ( 'Table'[Count] )
    )
VAR b =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER (ALL( 'Table'), [Product]=SELECTEDVALUE('Table'[Product]))
    )
RETURN
 a/b
Multiple = 
VAR a =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER ( 'Table', [Single/Multiple] = "Single" )
    )
VAR b =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER ( 'Table', [Single/Multiple] = "Multiple" )
    )
RETURN
    b / ( a + b )

vjaneygmsft_1-1638958888209.png

 

 Since the values of non-existent rows can't be displayed in the matrix in powerbi, 0% can't be displayed. 

But if you use table visual, it can be displayed.

Like this:

Single = 
VAR a =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER ( 'Table', [Single/Multiple] = "Single" )
    )
VAR b =
    CALCULATE (
        SUM ( 'Table'[Count] ),
        FILTER ( 'Table', [Single/Multiple] = "Multiple" )
    )
RETURN
    a / ( a + b )+0

vjaneygmsft_2-1638958896178.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

 

Best Regards,
Community Support Team _ Janey

amitchandak
Super User
Super User

@mglomb , Try a measure like

divide(sum(Table[Count]), calculate(sum(Table[Count]), filter(allselected(table), Table[product] = max(Table[Product]))))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

I got an error message saying that are "Too many arguments were passed to the Sum function. The maximum argument count for the function is 1".

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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