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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Help with advance IF function

Hi Friends,

 

I was trying to insert "Last Result" using some Ifs Dax Function, but the result is always "Not Done" or Errors.

I just want to have in "Last Result" the last data in previous columns that are not "Not Done" and if all previous columns have "Not Done" so insert it.

 

I tried to search a solution in forum but I didn't find it.

 

Below an example table of what I want from my formula:

Nycso94_1-1651497609662.png

 

Thanks for all of you that want to help me.

 

1 ACCEPTED SOLUTION

Use below in a custom column in PQ

= [l=List.FirstN(List.RemoveItems(List.Reverse(List.RemoveFirstN(Record.ToList(_),1)),{"Not Done"}),1), r=if List.IsEmpty(l) then "Not Done" else Text.Combine(l)][r]

View solution in original post

7 REPLIES 7
KT_Bsmart2gethe
Impactful Individual
Impactful Individual

Hi @Anonymous,

 

Add a custom column, add code below:

Replacer.ReplaceValue(List.Last(List.Select(List.Skip(Record.ToList(_),1), each _ <> "Not Done")),null,"Not Done")

 

KT_Bsmart2gethe_0-1651683430511.png

 

Regards

KT

speedramps
Super User
Super User

Please can you provide an example table of the input data  and desired output report.

 You can do this using copy and paste.

Do not send a screen prints.
Tables are much better because can import date and create an example solution. 

Anonymous
Not applicable

Hi @speedramps ,

Thanks for your reply!

 

My raw data is like this table:

NameMay Survey ResultJune Survey ResultJuly Survey ResultAugust Survey Result
User1Not DoneNot DoneGoodNot Done
User2Not DoneGoodBadNot Done
User3GoodBadGoodBad
User4BadGoodNot DoneNot Done
User5Not DoneNot DoneNot DoneNot Done

 

I want to create in PBI another column that has result of the last column with "Good" or "Bad" and if there isn't any "Good" or "Bad" insert "Not Done" (as the table that I sent in the post).

 

Thanks!

Use below in a custom column in PQ

= [l=List.FirstN(List.RemoveItems(List.Reverse(List.RemoveFirstN(Record.ToList(_),1)),{"Not Done"}),1), r=if List.IsEmpty(l) then "Not Done" else Text.Combine(l)][r]
speedramps
Super User
Super User

Hi Nycso94

Try this  and click thumbs up and Accept As Solution please ! 

 

Last result =
VAR usermaxdate =
CALCULATE(
MAX(Surveys[Date]),
ALLEXCEPT(Surveys,Surveys[User])
)

RETURN
CALCULATE(
MAX(Surveys[Result]),
Surveys[Date] = usermaxdate
)
Greg_Deckler
Community Champion
Community Champion

@Anonymous Is that how your raw data looks? If so, I highly recommend that you unpivot your month columns in Power Query and add an index or something so that you can determine which rows are earlier or later. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler ,

Thanks for your reply!

 

Yes, my raw data are that.

For my purpose is no matter if columns are dates or something else.

The importance is "Last Result" give me the last column (in orange table, because they are ordered correctly) that is "Good" or "Bad" and if there is no column with that 2 result so give me "Not Done".

Now I don't know if your suggest fit with my reply.

 

Thank you!

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors