Forum Discussion

rayishome's avatar
rayishome
Icon for Resolver I rankResolver I
4 years ago
Solved

Dax Query to group by multiple categories from one table

We have an attribute table that stores dynamic atributes about each product.  For example the table structure is the following   Product, Attribute Name, Attribute Property A,Color,Red A,Shape, B...
  • AlexisOlson's avatar
    4 years ago

    You can calculate a pivoted version and then do a SUMMARIZE or GROUP BY.

     

    Summary =
    VAR PivotCols =
        SUMMARIZECOLUMNS (
            T[Product],
            "Region", CALCULATE ( SELECTEDVALUE ( T[Property] ), T[Name] = "Region" ),
            "Color",  CALCULATE ( SELECTEDVALUE ( T[Property] ), T[Name] = "Color" )
        )
    RETURN
        GROUPBY ( PivotCols, [Region], [Color], "Count", SUMX ( CURRENTGROUP (), 1 ) )

     

    I don't know how well this will perform for big/complex models but at least it does in principle.