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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
makcim392
Advocate I
Advocate I

Is there a way to execute an if statement row by row?

Hi everyone,

 

I'm trying to get the top 20 percent of some clients. I'd like to create a filter which looks at the client data, if they are on the top 20 percent, write the value, if not, leave it blank. So that then I can filter in a table, summing the rows that have data (leaving the blank values outside the calculation). All these values summed (displayed in a row), are compared against some dates (which are in columns, the dates I mean)

 


Problem is that I cannot execute an if statement row by row. I'm comparing 2 values from the same row as an assertion, and leaving it blank if its lower than the other value, otherwise copy the value from one of the values I'm comparing in the statement. 

I'm also having issues with the last part, for some reason power bi isn't suggesting the column I want to use for copying the value. 

 

 

Thanks!

2 ACCEPTED SOLUTIONS
VasTg
Memorable Member
Memorable Member

@makcim392 

 

Yes.. Two options.

 

1. Create a conditional column or custom column in Query editor(Transform data )

 

or 

2. Create a calculated column and write DAX

image.png

If it helps, mark it as a solution

Kudos are nice too

Connect on LinkedIn

View solution in original post

v-yuta-msft
Community Support
Community Support

@makcim392 ,

 

If you want to achieve this in power query, you can create a custom column in query editor, you can refer to doc:

https://docs.microsoft.com/en-us/power-bi/desktop-add-custom-column

 

In you want to add a new column in table using dax, please create a calculate column using dax function IF():

https://docs.microsoft.com/en-us/dax/if-function-dax

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yuta-msft
Community Support
Community Support

@makcim392 ,

 

If you want to achieve this in power query, you can create a custom column in query editor, you can refer to doc:

https://docs.microsoft.com/en-us/power-bi/desktop-add-custom-column

 

In you want to add a new column in table using dax, please create a calculate column using dax function IF():

https://docs.microsoft.com/en-us/dax/if-function-dax

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @makcim392 ,

 

check this out.

SUMX

Returns the sum of an expression evaluated for each row in a table.

https://docs.microsoft.com/en-us/dax/sumx-function-dax

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


amitchandak
Super User
Super User
VasTg
Memorable Member
Memorable Member

@makcim392 

 

Yes.. Two options.

 

1. Create a conditional column or custom column in Query editor(Transform data )

 

or 

2. Create a calculated column and write DAX

image.png

If it helps, mark it as a solution

Kudos are nice too

Connect on LinkedIn

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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