Forum Discussion

TimmK's avatar
TimmK
Icon for Helper IV rankHelper IV
3 years ago
Solved

Bar Chart Group By

I have the simple FACT table "Piece" with the columns "Piece Key" and "Duration". A piece key may occur multiple times (as seen in the left table below). Yet, I want to group by "Piece Key" to get th...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi TimmK ,

     

    You need to create a table with data generateseries from 0 to max value (60) for X aixs in column chart.

    X aixs = 
    VAR _SUMMARIZE =
        SUMMARIZE (
            ALL ( 'Piece' ),
            'Piece'[Piece Key],
            "SumDuration", SUM ( 'Piece'[Duration] )
        )
    RETURN
        GENERATESERIES ( 0, MAXX ( _SUMMARIZE, [SumDuration] ), 1 )

    Measure:

    Count = 
    VAR _SUMMARIZE =
        SUMMARIZE (
            ALL ( 'Piece' ),
            'Piece'[Piece Key],
            "SumDuration", SUM ( 'Piece'[Duration] )
        )
    RETURN
        COUNTAX (
            FILTER ( _SUMMARIZE, [SumDuration] = MAX ( 'X aixs'[X aixs] ) ),
            [Piece Key]
        )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.