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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
PradipMCT
Resolver II
Resolver II

Write IF function with in Table Rows

Hi Friends,

 

Thanks for your help. 

 

I am working on a table as shown in the screenshot. I want to write IF function in the table rows. So far i have written the functions like, Table.Skip, Table.FillDown, Table.PromoteHeaders etc. I am unable to figure out how to write IF function in Power Query. 

 

Kindly help me if i have to write a funciton, if value is greater than a certain number then it should return true else false. 

 

Regards,

PradipPower Query function.png

7 REPLIES 7
gpoggi
Responsive Resident
Responsive Resident

Hi @PradidMCP,

Uhmm I’m not in my laptop right now, but what if you expand that Filldown column, once expanded filter or replace using M code the desired column and once you finish and get what you need, select first columns (from year to Custom) go to transform, Group By and select All Rows as Operation and check if you get what you need.

Let me know if this helps.


Regards,

Gian Carlo Poggi
Nathaniel_C
Super User
Super User

Hi @PradipMCT ,

 

Please see picture below. To add an if column, go to Add Column, select Condition Column, and fill in the boxes.  You may add additional if statements.  If you look at the function bar after you have done this, you will see the M language terminology for this.

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

 

IF in pq.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @Nathaniel_C 

 

Thanks a ton for responding. 

 

I know this way to write IF Function. My question was how to write IF function in the Row Table as shown/highlighted below in the screenshot. In those Row Tables, I would like to write IF function that is applicable to all the rows not just the current table. These tables are hidden inside the row. Hope i could make it simpler to understand!

 

Pradip Pardeshi

Microsoft Certified Trainer

Pradip's Youtube Channel

Power Query function.png

Hi @PradipMCT ,

I have heard that @ImkeF is the one to go to for M language questions!

Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @Nathaniel_C 

 

Thanks for tagging him to the post. Appreciate it.

 

@ImkeF Can you please help me with my query?

 

Pradip Pardeshi

Microsoft Certified Trainer

Pradip's Youtube Channel

Not sure about your request: What shall the if-statement do? Do you want to use it in a Table.AddColumn-comand on those nested tables?

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi, @ImkeF  Thanks for responding. I have a column in which a word total is written. I would like to remove only the rows that contain the total row. I thought I can use the logic, i.e. if the cell contains the word "TOTAL" I will filter them out using an additional column and use IF in it. Otherwise, also I would like to know if we can write IF Function in such situation. Regards, Pradip Pardeshi

Pradip's Youtube Channel

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Top Solution Authors
Top Kudoed Authors