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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
DonapatiSP_3105
New Member

Total Label Value into variable - Stacked bar chart

In a stacked bar chart, i want to show percentage of each stack in a bar. I have tried using below. This worked well for many other reports. In a particular report, i get only 100%. I have tried all combinations to achieve it.

 

% Amended = calculate(count(Total_Amended[RegistrationNumber]))/CALCULATE(COUNT(Total_Amended[RegistrationNumber]),ALLSELECTED(Total_Amended[Status]))
DonapatiSP_3105_2-1629352391003.png

 


 

I want to get a value of total of the bar into a variable. Is it possible?
2 ACCEPTED SOLUTIONS

Hi @DonapatiSP_3105 ,

 

Can you share your .pbix file for test?

Remember to remove the confidential information.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

View solution in original post

v-kelly-msft
Community Support
Community Support

Hi @DonapatiSP_3105 ,

 

Try:

% Amended =
DIVIDE (
    CALCULATE (
        COUNT ( Total_Amended[RegistrationNumber] ),
        FILTER (
            ALLSELECTED ( Total_Amended ),
            Total_Amended[New_Status] = MAX ( Total_Amended[New_Status] )
                && Total_Amended[RegionName] = MAX ( Total_Amended[RegionName] )
        )
    ),
    CALCULATE (
        COUNT ( Total_Amended[RegistrationNumber] ),
        FILTER ( ALLSELECTED ( Total_Amended ), [RegionName] = MAX ( [RegionName] ) )
    )
)

I made a simple sample for reference,you will see below in my example:

vkellymsft_0-1630485883442.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my areply as a solution!

 

View solution in original post

5 REPLIES 5
DonapatiSP_3105
New Member

I was getting 100% always because the given denominator used for calculating percentage are coming from different table using relationship. once that is corrected, the values were coming as expected.

v-kelly-msft
Community Support
Community Support

Hi @DonapatiSP_3105 ,

 

Try:

% Amended =
DIVIDE (
    CALCULATE (
        COUNT ( Total_Amended[RegistrationNumber] ),
        FILTER (
            ALLSELECTED ( Total_Amended ),
            Total_Amended[New_Status] = MAX ( Total_Amended[New_Status] )
                && Total_Amended[RegionName] = MAX ( Total_Amended[RegionName] )
        )
    ),
    CALCULATE (
        COUNT ( Total_Amended[RegistrationNumber] ),
        FILTER ( ALLSELECTED ( Total_Amended ), [RegionName] = MAX ( [RegionName] ) )
    )
)

I made a simple sample for reference,you will see below in my example:

vkellymsft_0-1630485883442.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my areply as a solution!

 

mahoneypat
Microsoft Employee
Microsoft Employee

FYI that you dont need the first CALCULATE in that expression.  Also, your popup shows a "New_Status" field but your expression removed the filter from the "Status" column.  Did you just rename for visual?  If not, you need to use the legend column in your ALLSELECTED.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hey Pat,

 

Thanks for your response. Yes, calculate is not need in the numerator. I had removed filter which was applied and didnt remove calculate.

 

Yes, "New_Status" field is the right filter. I had renamed it for the visual.  I had first tried with legend column in ALLSELECTED, i was getting 100% across.

Hi @DonapatiSP_3105 ,

 

Can you share your .pbix file for test?

Remember to remove the confidential information.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.