Forum Discussion

sbuster's avatar
sbuster
Icon for Helper I rankHelper I
3 years ago
Solved

DAX formula or new table

I have a situation where my fact table contains many records for the same key, on the same day.  I would like to summarize the data by day and identify the key with the most entries (i.e. the leader ...
  • ppm1's avatar
    3 years ago

    Here is a simpler measure to do that (replace Records with your actual table name). To make it even more performant, it gets the leader and their count in one measure, and concatenate them together. Because it includes the Date, the "total" will show the value for the max day. Note this does not handle ties. It just returns one of the tied values. To handle ties, you could use concatenatex().

     

     

    Leader-Count =
    VAR vSummary =
        SUMMARIZE (
            Records,
            Records[ID],
            Records[Date],
            "Count", COUNTROWS ( Records )
        )
    VAR vTop1 =
        TOPN ( 1, vSummary, [Count], DESC )
    RETURN
        MINX ( vTop1, Records[ID] ) & "-"
            & AVERAGEX ( vTop1, [Count] )

     

    Pat