Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

DAX expression for ROW_NUMBER() PARTITION BY ORDER

Hello,

 

I am trying to convert the SQL stetment to DAX

"ROW_NUMBER() OVER(PARTITION BY CONCAT(com.COMPANY, CI.CONFIGURATION_ITEM) ORDER BY COUNT(QC.QUICK_CODE) desc) AS RN" 

5 Replies

  • Anonymous , A Rank measure

    Rankx(all(com.COMPANY, CI.CONFIGURATION_ITEM)  , calculate(COUNT(QC.QUICK_CODE) ) ,,desc, dense)

     

    refer, if there are ties

    Rank Tie breaker
    https://community.powerbi.com/t5/Community-Blog/Breaking-Ties-in-Rankings-with-RANKX-Using-Multiple-Columns/ba-p/918655
    https://databear.com/how-to-use-the-dax-rankx-function-in-power-bi/

     

     

    For Rank Refer these links
    https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak  I am getting an error while implementing this DAX function.

       

      DAX:

      RANKX(ALL(FCT_0013_SN_INCIDENT[COMPANY_NAME], DIM_CI_CLASS[CONFIGURATION_ITEM]),CALCULATE(COUNT(QUICK_CODE[QUICK_CODE])),,DESC,Dense)

       

      Error Message :

      "All column arguments of the ALL/ALLNOBLANKROW/ALLSELECTED/REMOVEFILTERS function must be from the same table."

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, Anonymous ;

    Can you share a simple example and the desired output? and Relation between your tables?

     

    It makes it easier to give you a solution.


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, Anonymous ;

    Is your problem solved? If so, Would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I suppose we'll find out after scrolling through 5 pages of people saying I have the same issue. My guess is there is no adequaute solution as per usual but as long as we can tick that box and close it officially, I suppose that's good enough