Forum Discussion
How can I get 0 count for missing component
- 1 year ago
Hi EaglesTony
1. Create distinct lists of keys table and components table using DAX:
For key table KeysList = DISTINCT('IssueComponents'[Key]) For Component Table ComponentsList = DISTINCT('tblComponentName (2)'[ComponentName])
2. Create another table that performs a cross join of keys and components:KeyComponentMatrix = GENERATE( KeysList, SELECTCOLUMNS(ComponentsList, "ComponentName", ComponentsList[ComponentName]) )
3. In the KeyComponentMatrix, add a calculated column to evaluate whether each component is present for a given key:ComponentPresent = IF ( CALCULATE ( COUNTROWS('IssueComponents'), FILTER ( 'IssueComponents', 'IssueComponents'[Key] = KeyComponentMatrix[Key] && 'IssueComponents'[ComponentName] = KeyComponentMatrix[ComponentName] ) ) > 0, "Y", "N" )
I have attached a snapshot for the tables i have created , please review it.
If this post helps , kindly mark it as Accepted Solution. Appreciate your Kudos.Regards,
Karpurapu D.
I can't download the .pbix due to business reasons. Is there a code snippet here of how you did it ?
Hi EaglesTony
1. Create distinct lists of keys table and components table using DAX:
For key table
KeysList = DISTINCT('IssueComponents'[Key])
For Component Table
ComponentsList = DISTINCT('tblComponentName (2)'[ComponentName])
2. Create another table that performs a cross join of keys and components:
KeyComponentMatrix =
GENERATE(
KeysList,
SELECTCOLUMNS(ComponentsList, "ComponentName", ComponentsList[ComponentName])
)
3. In the KeyComponentMatrix, add a calculated column to evaluate whether each component is present for a given key:
ComponentPresent =
IF (
CALCULATE (
COUNTROWS('IssueComponents'),
FILTER (
'IssueComponents',
'IssueComponents'[Key] = KeyComponentMatrix[Key]
&& 'IssueComponents'[ComponentName] = KeyComponentMatrix[ComponentName]
)
) > 0,
"Y",
"N"
)
I have attached a snapshot for the tables i have created , please review it.
If this post helps , kindly mark it as Accepted Solution. Appreciate your Kudos.
Regards,
Karpurapu D.
- EaglesTony1 year agoPost Prodigy
Is there a way to show them across a single row instead of multiple rows ?
I was thinking Groupby ?
- v-karpurapud1 year agoCommunity Support
Hi EaglesTony
If possible, try to download the PBIX file to your personal device. This will help you have a better understanding of the logic.