Forum Discussion

4-3-3's avatar
4-3-3
Icon for Helper I rankHelper I
7 years ago
Solved

How do you GROUPBY two collumns with DAX?

I have a table that has multiple records for each day of the year for multiple entities. I need to create a column that will flag the newest record for each day as per the below example. Can someone please help me to achieve this with DAX?

branchIDdateamountrecordedlatest
123415/10/201922015/10/2019 
123415/10/201922516/10/2019 
123415/10/201924517/10/2019yes
567815/10/201911515/10/2019 
567815/10/201913016/10/2019 
567815/10/201914217/10/2019yes
  • Hi 4-3-3 ,

    I modified my formula that you can have a try.

    Flag = 
    var max_recorded = CALCULATE(MAX('Table'[recorded]),ALLEXCEPT('Table','Table'[date]))
    return
    IF('Table'[recorded] = max_recorded,"Yes",BLANK())

     

    Best Regards,

    Xue Ding

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

6 Replies

    • 4-3-3's avatar
      4-3-3
      Icon for Helper I rankHelper I

      Thanks for your input. Unfortunatetly that example only grouping by one column and I need this to look at two..

      • v-xuding-msft's avatar
        v-xuding-msft
        Icon for Community Support rankCommunity Support

        Hi 4-3-3 ,

        I created a measure that may help you. 

        Measure = 
        var max_recorded = CALCULATE(MAX('Table'[recorded]),ALLEXCEPT('Table','Table'[branchID]))
        return
        IF(MAX('Table'[recorded]) = max_recorded,"Yes",BLANK())

        Best Regards,

        Xue Ding

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