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
azaterol
Helper V
Helper V

Sales in percentage

Hello all,

I have a matrix of each main product group. If you click on the main product group, the matrix will open and the items will pop up. 
Already there is the quantity and the sales. 

 

Now I want create a measure which calculate the sales in percentage of the total sales. 

 

pbi_new.PNG

 

 

Have you any ideas?

Thank you all for your answers

--

azaterol

 

 

 

1 ACCEPTED SOLUTION

@azaterol I adjusted the code to your model:

 

% Parent 2 = 
VAR Numerator = SUM('Table'[Sales])
VAR Denominator =
    SWITCH (
        TRUE(),
        ISINSCOPE ( 'Table'[Items + number] ), CALCULATE ( SUM('Table'[Sales]), ALLSELECTED('Table'), VALUES('Table'[Main product group]) ),
        ISINSCOPE ( 'Table'[Main product group] ), CALCULATE ( SUM('Table'[Sales]), ALLSELECTED('Table')),
        Numerator
    )
VAR Result =
    DIVIDE (
        Numerator,
        Denominator
    )
RETURN
    Result

 

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

3 REPLIES 3
SpartaBI
Community Champion
Community Champion

@azaterol check out this pattern and adjust it to your model:
https://www.daxpatterns.com/hierarchies/


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

@azaterol I adjusted the code to your model:

 

% Parent 2 = 
VAR Numerator = SUM('Table'[Sales])
VAR Denominator =
    SWITCH (
        TRUE(),
        ISINSCOPE ( 'Table'[Items + number] ), CALCULATE ( SUM('Table'[Sales]), ALLSELECTED('Table'), VALUES('Table'[Main product group]) ),
        ISINSCOPE ( 'Table'[Main product group] ), CALCULATE ( SUM('Table'[Sales]), ALLSELECTED('Table')),
        Numerator
    )
VAR Result =
    DIVIDE (
        Numerator,
        Denominator
    )
RETURN
    Result

 

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Anonymous
Not applicable

 

 

Add again your sales measure the sales field and click fiel on visualisation pane

JamesFr06_0-1652517869557.png

and show as percentage of taotal and it should work

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.