Forum Discussion
Lookup & Concatenate Values in a Matrix
- 1 year ago
Hi Dilbertfan
Try the below DAX:
Look Up & Match Use Case (Concatenate Dataset) =
VAR UseCaseRow = SELECTEDVALUE('fctSiPAssets 1'[UseCaseNo])
VAR UseCaseCol = SELECTEDVALUE('fctSiPAssets 2'[UseCaseNo])
-- Get all datasets selected in slicers
VAR SelectedDataset1 = VALUES('fctSiPAssets 1'[Dataset ID])
VAR SelectedDataset2 = VALUES('fctSiPAssets 2'[Dataset ID])
-- Build dataset combinations via CROSSJOIN
VAR AllDatasetCombinations =
ADDCOLUMNS(
CROSSJOIN(
SelectedDataset1,
SelectedDataset2
),
"Dataset1_Alias", [Dataset ID],
"Dataset2_Alias", [Dataset ID] )
-- Filter combinations by UseCase intersection
VAR FilteredCombinations =
ADDCOLUMNS(
AllDatasetCombinations,
"CombinationText",
VAR CurrentDataset1 = [Dataset1_Alias]
VAR CurrentDataset2 = [Dataset2_Alias]
-- Lookup Outcome
VAR OutcomeFound =
LOOKUPVALUE(
'DatasetOutcome'[Outcome],
'DatasetOutcome'[Dataset 1], CurrentDataset1,
'DatasetOutcome'[Dataset 2], CurrentDataset2 )
-- Check if datasets match row and column UseCase
VAR MatchRow =
CALCULATE(
COUNTROWS('fctSiPAssets 1'),
'fctSiPAssets 1'[Dataset ID] = CurrentDataset1,
'fctSiPAssets 1'[UseCaseNo] = UseCaseRow
) > 0
VAR MatchCol =
CALCULATE(
COUNTROWS('fctSiPAssets 2'),
'fctSiPAssets 2'[Dataset ID] = CurrentDataset2,
'fctSiPAssets 2'[UseCaseNo] = UseCaseCol
) > 0
RETURN
IF(MatchRow && MatchCol && NOT ISBLANK(OutcomeFound),
CurrentDataset1 & " & " & CurrentDataset2 & " = " & OutcomeFound,
BLANK() ) )
RETURN
CONCATENATEX( FILTER(FilteredCombinations, NOT ISBLANK([CombinationText])), [CombinationText], UNICHAR(10) )
Hi Dilbertfan
We were following up to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. Could you please confirm if your query has been resolved the solution provided by freginier ? If it has, kindly mark the helpful response and accept it as the solution. This will help other community members resolve similar issues more efficiently. If not, please provide detailed information so we can assist you better.
Regards,
Karpurapu D,
Microsoft Fabric Community Support Team.