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
grsmith
Frequent Visitor

Clustered Bar Chart - Percent of category/legend

I'm looking for assistance with a clustered bar chart.  I am struggling to create a measure that gives me a % of a category([Project Type] - added as Legend), not % of grand total.

 

I have a number of slicers on my report; so would need the % of the category ([Project Type]) to adjust if the slicer modifies the filter. I tried creating a measure for this (but this seems to just replicate the % of GT):

 

Turnaround_%_of_projects = COUNT(Project_Tracking[Weeks to Turnaround]) / CALCULATE( COUNT( Project_Tracking[Weeks to Turnaround]), ALLSELECTED(Project_Tracking))

 

When I tried using ALLEXCEPT - and including all of the fields from my slicers, my denominator ends up being huge for some reason.  If I tried using KEEPFILTERS with ALLEXCEPT, then the denominator does not seem to stay the same per category...

 

Turnaround_%_of_projects = COUNT(Project_Tracking[Project Type]) / CALCULATE( COUNT( Project_Tracking[Project Type]),ALLSELECTED (Project_Tracking), KEEPFILTERS( ALLEXCEPT( Project_Tracking,Project_Tracking[Project Type])))

 

In visual terms, expect the each category (Legend item) to add up to 100% (e.g. the dark bars below add to 48%)

 

 Untitled1.png

 

I would appreciate any assistance / insight anyone has on this.

 

My data looks like the below:

Untitled2.png

 

I essentially need it to show the below for the clustered chart to show the correct %s:

Untitled3.png

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

@grsmith,

 

You may use the following DAX to create a new table.

Table =
ADDCOLUMNS (
    SUMMARIZE (
        Project_Tracking,
        Project_Tracking[Project Type],
        Project_Tracking[Weeks to Turnaround],
        "Count of Projects", COUNTROWS ( Project_Tracking )
    ),
    "% of Project Type", [Count of Projects]
        / COUNTROWS (
            FILTER (
                Project_Tracking,
                Project_Tracking[Project Type] = EARLIER ( Project_Tracking[Project Type] )
            )
        )
)
Community Support Team _ Sam Zha
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

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@grsmith,

 

You may use the following DAX to create a new table.

Table =
ADDCOLUMNS (
    SUMMARIZE (
        Project_Tracking,
        Project_Tracking[Project Type],
        Project_Tracking[Weeks to Turnaround],
        "Count of Projects", COUNTROWS ( Project_Tracking )
    ),
    "% of Project Type", [Count of Projects]
        / COUNTROWS (
            FILTER (
                Project_Tracking,
                Project_Tracking[Project Type] = EARLIER ( Project_Tracking[Project Type] )
            )
        )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.