Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Stop Counting/Ranking and start again based on criteria

Hi Everyone,

 

I need help figuring out how to create DAX Calculated Column formula that will give me the rank based on [Update Date] within group [Case ID], but, it will stop ranking and start ranking again, if [Update Distance] is less than 5.

 

Below table shows the data I have and the output I am trying to get.
I used different methods using EARLIER / RANK, FILTER...., even aksed CHATGPT for formula, but cannot figure it out.

Please help.

 

Case IDUpdate DateRANKUpdate Distance What I need
117/03/20231  1
118/03/202321 2
125/03/202337 1
126/03/202341 2
127/03/202351 3
209/03/20231  1
213/03/202324 2
215/03/202332 3
230/03/2023417 1
315/03/20231  1
411/03/20231  1
415/03/202324 2
  • Anonymous 

    pls try this

    Column = 
    var _last=maxx(FILTER('Table','Table'[Update Distance]>=5&&'Table'[Case ID]=EARLIER('Table'[Case ID])&&'Table'[RANK]<=EARLIER('Table'[RANK])),'Table'[RANK])
    return if('Table'[Update Distance]>=5, 1,if(ISBLANK(_last),'Table'[RANK]-_last, 'Table'[RANK]-_last+1))

3 Replies

  • Anonymous 

    pls try this

    Column = 
    var _last=maxx(FILTER('Table','Table'[Update Distance]>=5&&'Table'[Case ID]=EARLIER('Table'[Case ID])&&'Table'[RANK]<=EARLIER('Table'[RANK])),'Table'[RANK])
    return if('Table'[Update Distance]>=5, 1,if(ISBLANK(_last),'Table'[RANK]-_last, 'Table'[RANK]-_last+1))

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks ryan_mayu 

      This works like a charm 🙂
      I now need to figure out what you did there! 🙂

      Much appreciated