Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hello_MTC
Helper III
Helper III

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.

 

Capture.JPG

 

 

2 ACCEPTED SOLUTIONS
SpartaBI
Community Champion
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:

SpartaBI_0-1656062978751.png

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

Never mind! I solved it!

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

View solution in original post

9 REPLIES 9
hello_MTC
Helper III
Helper III

What if I want to put filter on column(user_type)?

@hello_MTC you mean you want to the rank to start over for each user type?

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

@hello_MTC can you maybe share a sample data so I could copy it to Power BI and send back the result?

how to share

@hello_MTC either you share a sample PBIX (through a link from onedrive/gdrive/dropbox/etc or just create a sample data in excel and copy paste the table to the message here.

Never mind! I solved it!

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

@hello_MTC Great! 🙂
Will appreciate your kudos on my messages :))
P.S. Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. 
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂

SpartaBI
Community Champion
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:

SpartaBI_0-1656062978751.png

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.