- Forums
- Get Help with Power BI
- Desktop
- Service
- Report Server
- Integrations with Files and Services
- Mobile Apps
- Developer
- DAX Commands and Tips
- Let's Talk Data
- Custom Visuals Development Discussion
- Community Support
- Welcome to the Community
- Community Feedback
- Community Help Blog
- Training and Consulting
- Dashboard in a Day
- EdX Specific Training Discussion Forum

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Microsoft Power BI Community
- Forums
- Get Help with Power BI
- Desktop
- Re: Sum a Measure Across 2 Layers of Categorisatio...

Topic Options

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

mjholland

Regular Visitor

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

12-05-2017
08:15 AM

Hi,

I'm using the following DAX measure to work out if a KPI for a particular category has been achieved:

KPI Achieved = SUMX (

Category,

IF (Category[Category] = "Beverages",if([%Avg]>=1,1,0),

IF (Category[Category] = "Confectionery Homestock",if([%Avg]>=1,1,0),

IF (Category[Category] = "Confectionery Impulse",if([%Avg]>=1,1,0),

IF (Category[Category] = "Food",if([%Avg]>=1,1,0),

IF (Category[Category] = "Purina",if([%TGT]>=1,1,0),

IF (Category[Category] = "Waters",if([% TGT]>=1,1,0),

BLANK() )

)

)))))

Each Category has a different target. I've used this function along with IF statements to see if the target is achieved for each category to highlight that with a 1. I'm then putting this measure into a table.

There's one added level of complexity - I need to show the results split across 2 higher categories - SS and MC, which would eventually give 12 KPIs, rathen than just 6. When I put this into the table the Total value at the end isn't the sum of all 12 categories, as follows:

So, for example, the second row should total to 11, not 6.

My Categories are in one table, my high Categories are in another and my list of IDs, on the left, is in one final table.

Can anyone help with this?

Thanks,

Mark

Solved! Go to Solution.

Report Inappropriate Content

Message 1 of 3

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

v-sihou-msft

Moderator

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

12-06-2017
11:44 PM

In your formula, it analysis on Category level only, it will not take the higher categories filter context, which means on grand total level, it will never calculate greater tha 6 since you only have 6 categories.

For your requirement, you should use a summarize table to have your calculation group on higher categories (SS, MC). You can try formula like below;

KPI Achieved = SUMX ( SUMMARIZE ( HighCategories, HighCategories[HighCategories], "KpiCount", SUMX ( Category, IF ( Category[Category] = "Beverages", IF ( [%Avg] >= 1, 1, 0 ), IF ( Category[Category] = "Confectionery Homestock", IF ( [%Avg] >= 1, 1, 0 ), IF ( Category[Category] = "Confectionery Impulse", IF ( [%Avg] >= 1, 1, 0 ), IF ( Category[Category] = "Food", IF ( [%Avg] >= 1, 1, 0 ), IF ( Category[Category] = "Purina", IF ( [%TGT] >= 1, 1, 0 ), IF ( Category[Category] = "Waters", IF ( [% TGT] >= 1, 1, 0 ), BLANK () ) ) ) ) ) ) ) ), [KpiCount] )

Regards,

2 REPLIES 2

Highlighted

v-sihou-msft

Moderator

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

12-06-2017
11:44 PM

In your formula, it analysis on Category level only, it will not take the higher categories filter context, which means on grand total level, it will never calculate greater tha 6 since you only have 6 categories.

For your requirement, you should use a summarize table to have your calculation group on higher categories (SS, MC). You can try formula like below;

KPI Achieved = SUMX ( SUMMARIZE ( HighCategories, HighCategories[HighCategories], "KpiCount", SUMX ( Category, IF ( Category[Category] = "Beverages", IF ( [%Avg] >= 1, 1, 0 ), IF ( Category[Category] = "Confectionery Homestock", IF ( [%Avg] >= 1, 1, 0 ), IF ( Category[Category] = "Confectionery Impulse", IF ( [%Avg] >= 1, 1, 0 ), IF ( Category[Category] = "Food", IF ( [%Avg] >= 1, 1, 0 ), IF ( Category[Category] = "Purina", IF ( [%TGT] >= 1, 1, 0 ), IF ( Category[Category] = "Waters", IF ( [% TGT] >= 1, 1, 0 ), BLANK () ) ) ) ) ) ) ) ), [KpiCount] )

Regards,

mjholland

Regular Visitor

Re: Sum a Measure Across 2 Layers of Categorisation, Multiple Column Headers

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

12-07-2017
01:33 AM

@v-sihou-msft this is perfect, it works a treat. Thank you so much.