Forum Discussion

Saxon10's avatar
Saxon10
Icon for Post Prodigy rankPost Prodigy
5 years ago
Solved

Concat based on the column text

  Hi,   In data table I have following columns are item and sales code. The sales code contain number and item code contain number and text.   I am trying ignore the following sales codes (<> fr...
  • AlexisOlson's avatar
    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 ( 90059010 ), { BLANK () } ), which can easily extend to much larger ranges of values.