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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

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
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.