Forum Discussion

Iamnvt's avatar
Iamnvt
Continued Contributor
6 years ago
Solved

Remove duplicate values after separator in Calculated Column

hi,   I need to use DAX calculate column function to remove the dupplicate value:   Input Expected Output A, A, B A, B B, B, C B, C   how to do this? thanks  
  • TomMartens's avatar
    TomMartens
    6 years ago

    Hey Iamnvt ,

     

    in Power Pivot you are able to use the CALENDAR function as is described here:

    https://www.sqlbi.com/articles/generating-a-series-of-numbers-in-dax/

     

    Here is the DAX statement from above now using the function CALENDAR:

     

    output calendar = 
    
    var _in = 'Table'[input]
    var _inAsPath = SUBSTITUTE(_in , ", " , "|")
    var _inPathLength = PATHLENGTH(_inAsPath)
    var _T = DISTINCT(SELECTCOLUMNS(ADDCOLUMNS(SELECTCOLUMNS(CALENDAR(1 , _inPathLength), "_Value", INT(''[Date])), "@item", PATHITEM(_inAsPath , [_Value] , TEXT)) , "@@item", [@item]))
    return
    CONCATENATEX(_T ,  [@@item], ", ")

     

    Regards,

    Tom