- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

# Dynamically Calculate Percentage for Line in "Line & Stacked Column" chart

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2016 03:31 AM

I have a stacked column chart showing the number of incidents In and Out of SLA, per Month.

I would now like to convert to a Line & Stacked Column chart, where the Line is the percentage of In SLA incidents, for that specific month.

My challenge is how do I create a measure that takes the total number of In and Out SLA values for each month, and then does a separate percentage calculation for each separate month.

If my understanding is correct, this percentage calculation must happen within the report itself, and I cannot do it within the query/dataset, as the percentage value must change depending on which date dimension I select for my Chart (E.g. Month, Quarter etc)

Solved! Go to Solution.

Accepted Solutions

## Re: Dynamically Calculate Percentage for Line in "Line & Stacked Column" chart

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2016 05:03 AM

Try something like:

MyMeasure = COUNT([Incidents])/CALCULATE(COUNT([Incidents]),ALL([Table]))

Putting that measure in your visualization should filter the numerator by the axis (month) but the denominator will always include all incidents because of the ALL clause. Thus, you *should* end up with what you want.

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

Proud to be a Datanaut!

All Replies

## Re: Dynamically Calculate Percentage for Line in "Line & Stacked Column" chart

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2016 05:03 AM

Try something like:

MyMeasure = COUNT([Incidents])/CALCULATE(COUNT([Incidents]),ALL([Table]))

Putting that measure in your visualization should filter the numerator by the axis (month) but the denominator will always include all incidents because of the ALL clause. Thus, you *should* end up with what you want.

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

Proud to be a Datanaut!

## Re: Dynamically Calculate Percentage for Line in "Line & Stacked Column" chart

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2016 10:53 PM

@SM thanks for the pointer!

I think I originally had something similar to what you suggested, however when approaching it with fresh eyes and your suggested code, I managed to also figure out (aka "guess") that while I was hoping to count the number of "Yes" in my InSLA column, my percentage always worked out to 100%, and this is because the COUNTA function was counting the blank values as well. I thus switched to using COUNTBLANK and subtracting the result from 1, as below.

PercentageInSLA = 1- (COUNTBLANK([InSLA])/CALCULATE(COUNTA([CaseNumber]),ALL(CRMCases[CaseNumber])))

Thanks again!