Forum Discussion
Concat based on the column text
- 5 years ago
The key here is the EXCEPT function to eliminate the stuff you don't want.
CONCOR = VAR Blacklist = { 9005, 9006, 9007, 9008, 9009, 9010, BLANK () } VAR Fulllist = CALCULATETABLE ( VALUES ( 'DATA (2)'[SALES CODE] ), ALLEXCEPT ( 'DATA (2)', 'DATA (2)'[ITEM] ) ) RETURN IF ( 'DATA (2)'[SALES CODE] IN Blacklist, BLANK (), CONCATENATEX ( EXCEPT ( Fulllist, Blacklist ), 'DATA (2)'[SALES CODE], "," ) )You can also write the Blacklist as UNION ( GENERATESERIES ( 9005, 9010 ), { BLANK () } ), which can easily extend to much larger ranges of values.
Hi Saxon10
Watch out. The description is inconsistent with the desired result (9011). Try this:
New Col =
VAR exclude_ =
UNION ( GENERATESERIES ( 9005, 9010 ), ROW ( "Value", BLANK () ) )
VAR auxT_ =
FILTER (
CALCULATETABLE (
DISTINCT ( Table1[SALES CODE] ),
ALLEXCEPT ( Table1, Table1[ITEM] )
),
NOT Table1[SALES CODE] IN exclude_
)
RETURN
IF (
NOT Table1[SALES CODE] IN exclude_,
CONCATENATEX ( auxT_, Table1[SALES CODE], ",", Table1[SALES CODE], ASC )
)
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
- AlexisOlson5 years ago
Super User
Yes, Saxon10 watch out for the discrepancies. In addition to the row with 9011, the bottom row in your post also does not match your description.
- Saxon105 years ago
Post Prodigy
Hi,
Thanks for your reply again.
Sorry I prepared the desired result manually that's the reason it went wrong. Thanks for address the discrepancies.
- Saxon105 years ago
Post Prodigy
Hi,
Thanks for your reply as well.
Sorry I prepared the desired result manually that's the reason it went wrong. Thanks for your solution as well. Nice to learn new function (Union)