cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
flent
New Member

Need IF statement to add 1 to the column instead of overwriting with the value of 1

Hi,

I come from a background in R so this may not be a feature in Power BI but I am hoping that is not the case.  I need to create a column using an IF statement, and I want the value of this new column to increase by 1 every time the condition is met and do nothing when the condition is not met.  I have tried IF(logical_operator, +1) but it still seems to be overwriting the previous data in the column, not adding 1 to the existing value of the cell.  Any help would be greatly appreciated, I have searched near and far for this answer.

 

Thanks

 

2 REPLIES 2
JustJan
Responsive Resident
Responsive Resident

Hi @flent ,

 

When I use RANKX in the calculated column, together with a row-level condition I can achieve what you are looking for, if I understand correctly of course. 

2020-03-28 18_55_28-Window.png

 

So in this case the rows where the condition is not met, there is no value. The rank is now based on the Index column, but that could be any column of course. 

 

Hope this helps,

 

Regards, 

 

Jan 

BA_Pete
Super User
Super User

Hi @flent ,

 

I don't think DAX will help you here due to the recursive nature of your requirement. However, Power Query/M Language can perform recursive functions e.g. https://www.poweredsolutions.co/2019/07/01/recursive-functions-in-power-bi-power-query/.

 

Sorry this isn't an instant solution to your query, but hopefully it gets you pointed in the right direction knowing that there is potentially a way.

 

Good luck.

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors