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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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