cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

IF statement combining multiple conditions from different columns and row just above

Hello All,

 

I am facing difficulties in translating the Excel formula below to Power Bi:

 

=IF(Q2=1;IF(M1="No";"No";L2);"NA")

 

For sensible reasons I cannot show a screenshot of data. However column Q is based on an IF statement and the output is either 1 or 2. Column M is a text column where output is "Yes" or "No" and column L is equal to a number (Average Time). As you can see in the formula, Q and L columns seek information in row 2 whereas column M seeks information in row 1. My data is layed out in a chronological way. Hence each row is connected to the above row and this is the reason why I need a formula to involve the current row with the one jsut above above. In excel it is very easy to combine multiple conditions of different format and located on different rows. However as I understood in Power Bi, we need to work with columns and formulas and cannot get around easily as in Excel and just select whichever cells in our formulas. 

 

I have explored several forums and videos and so far I know I must creat and index table (which I did) in order to refer to the row just above when including condition for column M. I aslo need to include functions such as Calcualte, Filter, Earlier, IF, SUM... However I have not find the right logic to develop my formula. I hope I have provided sufficient information to obtain help.

 

Thank you very much in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resident Rockstar
Resident Rockstar

Re: IF statement combining multiple conditions from different columns and row just above

@Dim24

 

Your direction is correct. Somehow index is necessary. You need to use earlier to the pervious value or next value.

 

Column = SUMX(FILTER('Sheet1 (2)','Sheet1 (2)'[index]=EARLIER('Sheet1 (2)'[index])-1),'Sheet1 (2)'[amount])

 

 

The entire DAX should be something like below. You can modify by yourself. Thanks

 

column =

VAR M= SUMX(FILTER('Sheet1 (2)','Sheet1 (2)'[index]=EARLIER('Sheet1 (2)'[index])-1),'Sheet1 (2)'[amount])

RETURN if(Q=1,IF(M="NO","No",L),"NA")

 

 

c1.JPG

Did I answer your question? Mark my post as a solution.Appreciate your Kudos!
Proud a to be a Datanaut!
Thanks and BR
Ryan

View solution in original post

1 REPLY 1
Highlighted
Resident Rockstar
Resident Rockstar

Re: IF statement combining multiple conditions from different columns and row just above

@Dim24

 

Your direction is correct. Somehow index is necessary. You need to use earlier to the pervious value or next value.

 

Column = SUMX(FILTER('Sheet1 (2)','Sheet1 (2)'[index]=EARLIER('Sheet1 (2)'[index])-1),'Sheet1 (2)'[amount])

 

 

The entire DAX should be something like below. You can modify by yourself. Thanks

 

column =

VAR M= SUMX(FILTER('Sheet1 (2)','Sheet1 (2)'[index]=EARLIER('Sheet1 (2)'[index])-1),'Sheet1 (2)'[amount])

RETURN if(Q=1,IF(M="NO","No",L),"NA")

 

 

c1.JPG

Did I answer your question? Mark my post as a solution.Appreciate your Kudos!
Proud a to be a Datanaut!
Thanks and BR
Ryan

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors