Forum Discussion

hello_MTC's avatar
hello_MTC
Helper III
4 years ago
Solved

Add a new Column using IF or any other functions

Hello,

I want to add a column(ID) in Power BI query editor same like I have added it in Excel using IF function. See picture below.

column(user_id) should be sorted out low to high.

 

 

 

  • Never mind! I solved it!

    ID2 = RANKX(FILTER('actdb users_outcome','actdb users_outcome'[user_type]="Victim"),'actdb users_outcome'[user_id],,ASC,Dense)

9 Replies

  • SpartaBI's avatar
    SpartaBI
    Community Champion

    hello_MTC is it ok if it will be in dax? You basically need a ranking column there.
    If yes, then you just want to write this calculated column:
    CALC = RANKX('Table', 'Table'[user_id],,ASC,Dense)

    I added a sample with differnet numbers:

     

     





          

    Showcase Report – Contoso By SpartaBI

      • hello_MTC's avatar
        hello_MTC
        Helper III

        Yes, I have user_type as Suspect, Witness Victim. And I want to filter this out by Victim only.