Reputation: 1
My SQL returns 2 columns with concatenated strings, I split both the columns in power query and I want to use DAX to do a comparison on the values in both the columns for every ID column. The measure should show the return the distinct count of ColumnA when Agency = Yes and when either of the mismatch conditions are met:
Please let me know the DAX that is needed for this situation. In SQL i used String_split to compare the values
Date | ColumnA | Agency | RegionA | RegionB |
---|---|---|---|---|
11/01/2024 | 123 | Yes | Phoenix | Phoenix |
11/01/2024 | 123 | Yes | Charlotte | |
11/08/2024 | 123 | Yes | Phoenix | Phoenix |
11/08/2024 | 123 | Yes | Charlotte | Charlotte |
11/01/2024 | 345 | No | Edison | |
11/01/2024 | 345 | No | Atlanta | |
11/01/2024 | 567 | Yes | Tampa | |
11/01/2024 | 567 | Yes | Raleigh | |
11/01/2024 | 567 | Yes | Memphis | |
11/08/2024 | 345 | Yes | Atlanta | Edison |
11/08/2024 | 345 | Yes | Edison | |
11/08/2024 | 567 | Yes | Tampa | Tampa |
11/08/2024 | 567 | Yes | Raleigh | Raleigh |
Wrote the query in SQL but user wants a drillthrough of the details that make the counts so trying to achieve the result with DAX
Upvotes: -1
Views: 34
Reputation: 6064
Assuming I correctly understand your requirements:
Mismatch Count =
VAR FilteredData =
FILTER (
'Table',
'Table'[Agency] = "Yes"
&& (
-- Condition 1: Either RegionA or RegionB is NULL
ISBLANK('Table'[RegionA]) || ISBLANK('Table'[RegionB])
||
-- Condition 2: Mismatch between RegionA and RegionB
'Table'[RegionA] <> 'Table'[RegionB]
)
)
VAR DistinctIDs = DISTINCT ( SELECTCOLUMNS ( FilteredData, "DistinctColumnA", 'Table'[ColumnA] ) )
RETURN
COUNTROWS ( DistinctIDs )
Upvotes: 0