Forum Discussion
Count of combinations of values (measures) in a table (summarizing by multiple values?)
Hey there.
I have a table visualizing the number of different channels held by an employee. I have to count how many times each combination and number of channels appears.
Thus, instead of full names, I have to somehow summarize this data and get the number of full names for each combination (see the second screenshot).
Also, these counters are measures that take into the account start and end dates of the employees, so that the data can be filtered dynamically by date. That's why a calculated column won't probably be a solution.
Here's how my data looks like:
resource_allocation table:
| allocation_code (PK) | FullName | start_date | end_date | Emails | Calls | Social |
| 1 | employee1 | 03/03/2020 | 08/11/2020 | 1 | 1 | 1 |
| 2 | employee2 | 01/01/2019 | 2 | |||
| ... | ... | ... | ... |
sdr_channels table:
| channel_code (PK) | allocation_code (FK) | sdr_channel |
| 1 | 1 | Emails |
| 2 | 1 | Calls |
| 3 | 1 | Social |
| 4 | 2 | Calls |
| ... | ... | ... |
Note: 'Emails', 'Calls' and 'Social' in the resource_allocation table are calculated columns. I use the following formula:
The measures-counters for the table visual are:
Where
Tables' relationships:
The result I want to achieve:
3 Replies
- parry2k
Super User
Anonymous your problem is not very clear. Read this post to get your answer quickly.
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490 - V-lianl-msft
Community Support
Hi Anonymous ,
Try this measure:
Measure = CALCULATE ( COUNT ( 'Table'[Full Name] ), FILTER ( ALL ( 'Table' ), COUNTROWS ( FILTER ( 'Table', 'Table'[Calls Counter] = EARLIER ( 'Table'[Calls Counter] ) && EARLIER ( 'Table'[Email Counter] ) = 'Table'[Email Counter] && 'Table'[Social Counter] = EARLIER ( 'Table'[Social Counter] ) ) ) ) )Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Thanks for your answer @V-lianl-msft .
However, I think I can't use EARLIER with a measure (while my counters are measures). The partEARLIER ( 'Table'[Calls Counter] )is underlined red and it says "Parameter is not the correct type".
Also, I can't edit this post properly for some reason, so I'll provide the additional info here...
Here's how my data looks like:
resource_allocation table:allocation_code (PK) FullName start_date end_date Emails Calls Social 1 employee1 03/03/2020 08/11/2020 1 1 1 2 employee2 01/01/2019 2 ... ... ... ...
sdr_channels table:channel_code (PK) allocation_code (FK) sdr_channel 1 1 Emails 2 1 Calls 3 1 Social 4 2 Calls ... ... ... Emails, Calls and Social in resource_allocation table are calculated columns, which look like this:
Calls = IF(CALCULATE ( MAX(resource_allocation[allocation_code]), FILTER(sdr_channels, sdr_channels[sdr_channel]="Calls" && resource_allocation[allocation_code]=sdr_channels[allocation_code]))<>BLANK(),"C")
The counter-measures look the following way:Calls counter = CALCULATE(CALCULATE(COUNT(resource_allocation[Calls]),FILTER(resource_allocation, resource_allocation[Allocated (HR)]=1),ALLEXCEPT(resource_allocation,resource_allocation[employee_code])))
Where the Allocated measure is:Allocated (HR) =VAR max_Selected_Date =IF(HASONEVALUE(Rolling_Calendar[Year]), MAX(Rolling_Calendar[Calendar]), TODAY())VAR min_Selected_Date =IF(HASONEVALUE(Rolling_Calendar[Year]), MIN(Rolling_Calendar[Calendar]), TODAY())RETURNCALCULATE(SWITCH(TRUE(),FIRSTNONBLANK ( resource_allocation[start_date], 1 ) <= max_Selected_Date &&FIRSTNONBLANK( resource_allocation[end_date], 1 ) >= min_Selected_Date,1,FIRSTNONBLANK ( resource_allocation[start_date], 1 ) <= max_Selected_Date &&MAX(resource_allocation[end_date])=BLANK(),1,0))