Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, I'm having this problem:
I have this 2 tables
and has a relationship 1 to many by OP, I would like to create a column that can lists every "new op" that have the same code of the "old op", I'm thinking in something like this:
or something like this
it's the same idea but different format, eather of these two should do the work, but so far i can not reach a column like that, any help would be very much appreciate.
Thanks.
Solved! Go to Solution.
Hi @Midguel,
You could add this formula as a calculated column to your old OP table.
All Codes Matching =
VAR TextString =
CONCATENATEX(
ALL(New OP), IF(OldOP[Code] = NewOP[Code], NewOP[New OP] & ","), ""
)
VAR Length = MAX( LEN(TextString) - 1, 0 )
RETURN
LEFT( TextString, Length )
It iterates through all the new OP table finding where the codes match that row and then concatenates the codes seperating by a comma. The rest of the DAX statement then removes the final comma that will occur as a result. You may need to adapt some of the column names to fit the tables and column names from your model.
Hope it helps!
Kris
You could try this as well:
AllCodes =
VAR OuterOPCode = OldOP[Code]
VAR SameCodeInNewTable =
FILTER ( ALL ( NewOP ), NewOP[Code] = OuterOPCode )
VAR Result =
CONCATENATEX ( SameCodeInNewTable, LOWER ( [New OP] ), ", " )
RETURN
Result
or
AllCodes2 =
VAR OuterOPCode = OldOP[Code]
VAR SameCodesInNewOP =
FILTER ( VALUES ( NewOP[Code] ), NewOP[Code] = OuterOPCode )
VAR Result =
CALCULATE (
CONCATENATEX ( VALUES ( NewOP[New OP] ), LOWER ( NewOP[New OP] ), ", " ),
SameCodesInNewOP,
ALL ( OldOP )
)
RETURN
Result
You could try this as well:
AllCodes =
VAR OuterOPCode = OldOP[Code]
VAR SameCodeInNewTable =
FILTER ( ALL ( NewOP ), NewOP[Code] = OuterOPCode )
VAR Result =
CONCATENATEX ( SameCodeInNewTable, LOWER ( [New OP] ), ", " )
RETURN
Result
or
AllCodes2 =
VAR OuterOPCode = OldOP[Code]
VAR SameCodesInNewOP =
FILTER ( VALUES ( NewOP[Code] ), NewOP[Code] = OuterOPCode )
VAR Result =
CALCULATE (
CONCATENATEX ( VALUES ( NewOP[New OP] ), LOWER ( NewOP[New OP] ), ", " ),
SameCodesInNewOP,
ALL ( OldOP )
)
RETURN
Result
Hi @Midguel,
You could add this formula as a calculated column to your old OP table.
All Codes Matching =
VAR TextString =
CONCATENATEX(
ALL(New OP), IF(OldOP[Code] = NewOP[Code], NewOP[New OP] & ","), ""
)
VAR Length = MAX( LEN(TextString) - 1, 0 )
RETURN
LEFT( TextString, Length )
It iterates through all the new OP table finding where the codes match that row and then concatenates the codes seperating by a comma. The rest of the DAX statement then removes the final comma that will occur as a result. You may need to adapt some of the column names to fit the tables and column names from your model.
Hope it helps!
Kris
Thank you all, @kriscoupe @AntrikshSharma both worked great, thanks.
I was thinking... is there a way too exclude from this new column the OP's that are the same? something like if "old op" == "new op", "don't add to the list".
Again, thank you for the help.
Just use the not equal to sign: <>
Yes, fixed with:
All Codes Matching =
VAR TextString =
CONCATENATEX(
ALL(New OP), IF(OldOP[Code] = NewOP[Code] && OldOP[OldOP] <> NewOP[NewOP], NewOP[New OP] & ","), ""
)
VAR Length = MAX( LEN(TextString) - 1, 0 )
RETURN
LEFT( TextString, Length )
Thank you.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
26 | |
20 | |
15 | |
12 |
User | Count |
---|---|
57 | |
49 | |
43 | |
19 | |
18 |