Forum Discussion
NuTek
9 years agoFrequent Visitor
Calculating overlap between selected groups
Given the following table and data: Group Task ===== ==== XYZ A XYZ C XYZ D XYZ E PDQ B PDQ C PDQ D PDQ E LUV ...
- 9 years ago
Hi NuTek,
You can use FIRSTNONBLANK/LASTNONBLANK function to get the first/last selected group.
First Selected Group = FIRSTNONBLANK(Table1[Group],1)
The formula below is for your reference.:smileyhappy:
% Overlap for first Selected Group = VAR firstSelectedGroup = FIRSTNONBLANK ( Table1[Group], 1 ) VAR count_of_overlap = CALCULATE ( DISTINCTCOUNT ( Table1[Task] ), FILTER ( Table1, CALCULATE ( COUNT ( Table1[Task] ), ALLSELECTED ( Table1[Group] ) ) = 2 ) ) + 0 VAR count_of_task_XYZ = CALCULATE ( DISTINCTCOUNT ( 'Table1'[Task] ), 'Table1'[Group] = firstSelectedGroup ) + 0 RETURN DIVIDE ( count_of_overlap, count_of_task_XYZ, 0 )Regards
v-ljerr-msft
9 years agoMicrosoft Employee
Hi NuTek,
Could you try using the formula below to create a measure, then just show the measure on the Card visual to see if it works?:smileyhappy:
% Overlap for XYZ =
VAR count_of_overlap =
CALCULATE (
DISTINCTCOUNT ( Table1[Task] ),
FILTER (
Table1,
CALCULATE ( COUNT ( Table1[Task] ), ALLSELECTED ( Table1[Group] ) ) = 2
)
) + 0
VAR count_of_task_XYZ =
CALCULATE ( DISTINCTCOUNT ( 'Table1'[Task] ), 'Table1'[Group] = "XYZ" ) + 0
RETURN
DIVIDE ( count_of_overlap, count_of_task_XYZ, 0 )Regards
NuTek
9 years agoFrequent Visitor
Thanks for the formula. The results look goodin your example... Is there a way to not have to hardcode the "XYZ" and replace that with the selected value?
- v-ljerr-msft9 years agoMicrosoft Employee
Hi NuTek,
You can use FIRSTNONBLANK/LASTNONBLANK function to get the first/last selected group.
First Selected Group = FIRSTNONBLANK(Table1[Group],1)
The formula below is for your reference.:smileyhappy:
% Overlap for first Selected Group = VAR firstSelectedGroup = FIRSTNONBLANK ( Table1[Group], 1 ) VAR count_of_overlap = CALCULATE ( DISTINCTCOUNT ( Table1[Task] ), FILTER ( Table1, CALCULATE ( COUNT ( Table1[Task] ), ALLSELECTED ( Table1[Group] ) ) = 2 ) ) + 0 VAR count_of_task_XYZ = CALCULATE ( DISTINCTCOUNT ( 'Table1'[Task] ), 'Table1'[Group] = firstSelectedGroup ) + 0 RETURN DIVIDE ( count_of_overlap, count_of_task_XYZ, 0 )Regards