Forum Discussion

su1337's avatar
su1337
Regular Visitor
8 years ago

DAX Script for TOTAL and CONCAT

 

1. I need a TOTAL column that will sum the number of 'Runs' for each 'Group'. --> TOTAL for group A would be 5

 

2. I need to combine like terms in the 'Type' column if the 'Group' and 'Project' are identical. --> So Group A would be listed as

 

ABlueWeb, Mobile5

 

 

 

 

Group Project Type Runs --> these are the column headers
ABlueWeb2
ABlueMobile3
BOrangeMobile1
CRedWeb4
CRedWeb3
CPinkWeb1
DYellowMobile2

6 Replies

  • ChrisMendoza's avatar
    ChrisMendoza
    Resident Rockstar

    su1337,

     

    If you are able to let the visual do some of the work for you, you can try the following as a measure:

     

    Measure = 
    IF(
        HASONEFILTER(TableName[Group]),
        CONCATENATEX(TableName,TableName[Type],", ",TableName[Type],ASC)
    )

    This will produce a visual Matrix or Table respectively as;

     



    • su1337's avatar
      su1337
      Regular Visitor

      The problem is that I need this script to run against the selected visual filters. I have the entire data filtered by date and other parameters so the script needs to take that into account.

       

      I wasnt sure if there was a way to save a visual as a table because that could help the problem I am experiencing. 

      • v-yulgu-msft's avatar
        v-yulgu-msft
        Microsoft Employee

        Hi su1337,

         

        That case, you can try ChrisMendoza's suggestion to create a measure which would return result conditionally taking slicer selection into account.

         

        Regards,

        Yuliana Gu

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi su1337,

     

    Alternatively, you can new a calculated table.

    Table5 =
    SUMMARIZE (
        table4,
        table4[Group],
        table4[Project],
        "Type", CONCATENATEX ( table4, table4[Type], "," ),
        "Runs", SUM ( table4[Runs] )
    )

     

    Best regards,

    Yuliana Gu