Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
I am stuck on converting a nested IF/AND statement from Excel to Power Query as a custom column. I have my data sorted in Power BI by the phone number, call date, and call time. I am stuck on how do the look up to the previous row and see if it meets the criteria. I am trying to tie the results to see the transfer routes of calls.
My excel formula is
=IF(J11=0,0,IF(AND(I11=5,J10=0),B10,IF(J11=J10,B10,0)))
I am looking to achieve column L for my output in my new custom colum.
This is the formula I have in power query but it not looking at the previous row above and not calculating as a IF/AND but as an IF/OR.
= Table.AddColumn(#"Expanded ACD Transfer Mapping", "Custom", each if [orig_recid] = 0 then 0 else if [call_type] = 5 then [record_id] else if [orig_recid] = [orig_recid] then [record_id] else null)
Solved! Go to Solution.
Hi @Anonymous
You need an Index column to refer the row above. One thing to consider, if there is a match in the first row, then no previous row, what should it return? you can wrap a try...otherwise
= Table.AddColumn(#"Added Index", "prior_recid", each if [orig_recid] = 0 then 0
else if ([call_type] = 5 and #"Added Index"[orig_recid]{[Index]-1}=0 ) or [orig_recid] = #"Added Index"[orig_recid]{[Index]-1} then #"Added Index"[record_id]{[Index]-1}
else null)
Hi @Anonymous
You need an Index column to refer the row above. One thing to consider, if there is a match in the first row, then no previous row, what should it return? you can wrap a try...otherwise
= Table.AddColumn(#"Added Index", "prior_recid", each if [orig_recid] = 0 then 0
else if ([call_type] = 5 and #"Added Index"[orig_recid]{[Index]-1}=0 ) or [orig_recid] = #"Added Index"[orig_recid]{[Index]-1} then #"Added Index"[record_id]{[Index]-1}
else null)
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |