cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KhanhTu
Frequent Visitor

Calcualte 100% stacked of each column in stacked visualization

Hello Power BI community

 

I Need to build a measure that can calculate 100% based on all categories for each month. I want to apply this measure to my visualized Stacked column Chart. (I know I can use a 100 % Stacked column chart to show the correct percentage) But I only want to show this measure in my tooltips and keep the original visualization.

This is my Dax code so far:

Percentage = DIVIDE([Total cases],CALCULATE([Total cases],ALLEXCEPT(SALESFORCE_CASES_FCT_20210429, SALESFORCE_CASES_FCT_20210429[CASE_ORIGIN (groups)],DIM_DATE[YYYY-MM])),0)
 
Just like in the example in the last picture. I want to find the measure with "51,97%" and apply it to the tooltips in the first visualization .
 
Thanks for help
 
Best Regards
Khanh

 



Original visualizaitonOriginal visualizaitongroup based of a columngroup based of a columnexampel.PNG
2 ACCEPTED SOLUTIONS
yingyinr
Community Support
Community Support

Hi @KhanhTu ,

You can update the formula of measure [Percentage] as below:

Note: please update the name of date field with the correct one in the table SALESFORCE_CASES_FCT_20210429 .

Percentage =
DIVIDE (
    [Total cases],
    CALCULATE (
        [Total cases],
        FILTER (
            ALLSELECTED ( 'SALESFORCE_CASES_FCT_20210429' ),
            FORMAT ( 'SALESFORCE_CASES_FCT_20210429'[Date], "YYYY-MM" )
                SELECTEDVALUE ( 'DIM_DATE'[YYYY-MM] )
        )
    ),
    0
)

yingyinr_2-1620201341909.png

Best Regards

Community Support Team _ Rena
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

KhanhTu
Frequent Visitor

Hi @_Rena
thanks you for your help.

I don't know why but Its also works when I tried with All function.

Percentage cases = DIVIDE([Totalcases],CALCULATE([Totalcases],ALL(SALESFORCE_CASES_FCT_20210429[Case_origin group])),0)

Best regards 
Khanh

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@KhanhTu , I think it should be the only case Origin in all except

 

Percentage = DIVIDE([Total cases],CALCULATE([Total cases],ALLEXCEPT(SALESFORCE_CASES_FCT_20210429, SALESFORCE_CASES_FCT_20210429[CASE_ORIGIN (groups)])),0)



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Hello amitchandak thanks for the answer.

 

However, I still experienced the issue.  Example, Its give me percentage of 4,41 % when it should be 40,74 %

KhanhTu_0-1620054826885.png

 

yingyinr
Community Support
Community Support

Hi @KhanhTu ,

You can update the formula of measure [Percentage] as below:

Note: please update the name of date field with the correct one in the table SALESFORCE_CASES_FCT_20210429 .

Percentage =
DIVIDE (
    [Total cases],
    CALCULATE (
        [Total cases],
        FILTER (
            ALLSELECTED ( 'SALESFORCE_CASES_FCT_20210429' ),
            FORMAT ( 'SALESFORCE_CASES_FCT_20210429'[Date], "YYYY-MM" )
                SELECTEDVALUE ( 'DIM_DATE'[YYYY-MM] )
        )
    ),
    0
)

yingyinr_2-1620201341909.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
KhanhTu
Frequent Visitor

Hi @_Rena
thanks you for your help.

I don't know why but Its also works when I tried with All function.

Percentage cases = DIVIDE([Totalcases],CALCULATE([Totalcases],ALL(SALESFORCE_CASES_FCT_20210429[Case_origin group])),0)

Best regards 
Khanh

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors