Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I am currently working on migrating a complete Tableau report into Power BI. The Tableau report is connected to an Alteryx workflow, which outputs data in .yxdb format. My goal is to fully replicate both the Tableau report and the underlying Alteryx data preparation logic within Power BI.
The challenge is that the Alteryx workflow includes several multi-row formulas, and I need to reproduce this logic entirely within Power Query (M language), without using DAX or external tools.
Has anyone here successfully converted complex Alteryx workflows (especially those using multi-row calculations) into Power Query steps? Any guidance, best practices, or examples would be greatly appreciated.
Attached 2 sample multi row formulas that is used in alteryx workflows Thanks in advance!
1. [Row-1:Index]+1
2.If [Row-1:ID]=[ID] && [Row-1:Group A]=[Group A]
then
[Row-1:Extract Date]
else
Null()
endif
Solved! Go to Solution.
Hi @nidish Use Table.AddIndexColumn to add indices and Table.Buffer to reference previous rows. For formulas like [Row-1:Index]+1, create an index column and add 1 to shift values. For conditional logic, use if...then...else with buffered tables to compare and derive values from prior rows. Break complex workflows into smaller steps for clarity and performance.
Hi @nidish ,
Thanks for using Microsoft Fabric Community and sharing your scenario.
Yes, it’s possible to replicate Alteryx multi-row formulas using Power Query without relying on DAX or external tools. To handle logic like [Row-1:Index] + 1 or conditional row comparisons, you can use an index column and a shifted self-join approach.
I tested the logic using this sample data:
Power Query steps used:
let
Source = Table.FromRows(
{
{"1", "A", "X", "01-01-2024"},
{"2", "A", "X", "02-01-2024"},
{"3", "A", "Y", "03-01-2024"},
{"4", "B", "X", "04-01-2024"},
{"5", "B", "X", "05-01-2024"}
},
{"Index", "ID", "Group A", "Extract Date"}
),
ChangedType = Table.TransformColumnTypes(Source, {
{"Index", Int64.Type}, {"ID", type text},
{"Group A", type text}, {"Extract Date", type date}
}),
AddedRowNumber = Table.AddIndexColumn(ChangedType, "RowNumber", 0, 1, Int64.Type),
PrevRows = Table.AddIndexColumn(ChangedType, "RowNumber", 1, 1, Int64.Type),
RenamedPrev = Table.RenameColumns(PrevRows, {
{"Index", "Prev_Index"},
{"ID", "Prev_ID"},
{"Group A", "Prev_Group A"},
{"Extract Date", "Prev_Extract Date"}
}),
Merged = Table.NestedJoin(AddedRowNumber, {"RowNumber"}, RenamedPrev, {"RowNumber"}, "PrevRow", JoinKind.LeftOuter),
Expanded = Table.ExpandTableColumn(Merged, "PrevRow", {
"Prev_Index", "Prev_ID", "Prev_Group A", "Prev_Extract Date"
}),
AddedIndexPlus1 = Table.AddColumn(Expanded, "Row-1_IndexPlus1", each if [Prev_Index] <> null then [Prev_Index] + 1 else null, Int64.Type),
AddedConditional = Table.AddColumn(AddedIndexPlus1, "Conditional Extract Date", each
if [Prev_ID] = [ID] and [Prev_Group A] = [Group A] then [Prev_Extract Date] else null, type nullable date),
#"Sorted Rows" = Table.Sort(AddedConditional,{{"Index", Order.Ascending}})
in
#"Sorted Rows"
Some best practices to keep in mind while implementing multi-row logic in Power Query:
Filter and remove unnecessary columns early to optimize performance
Use Table.Buffer for small lookup tables before merges, if reused
Clean and standardize key columns before joining
Perform merges and sorts later in the query chain when possible
Here are some resources which you might find useful:
Power Query - Methods to Refer to Previous Row - T... - Microsoft Fabric Community
Best practices when working with Power Query - Power Query | Microsoft Learn
Hope this helps. Please reach out for further assistance.
If this post helps, then please consider to Accept as the solution to help the other members find it more quickly.
Thank you.
Please find the attached .pbix file for reference.
Hi @nidish ,
We wanted to kindly follow up regarding your query. If you need any further assistance, please reach out.
Thank you.
Hi @nidish ,
Following up to see if your query has been resolved and if any of the responses helped.
If you need further assistance, feel free to reach out.
Thank you.
Hi @nidish ,
Thanks for using Microsoft Fabric Community and sharing your scenario.
Yes, it’s possible to replicate Alteryx multi-row formulas using Power Query without relying on DAX or external tools. To handle logic like [Row-1:Index] + 1 or conditional row comparisons, you can use an index column and a shifted self-join approach.
I tested the logic using this sample data:
Power Query steps used:
let
Source = Table.FromRows(
{
{"1", "A", "X", "01-01-2024"},
{"2", "A", "X", "02-01-2024"},
{"3", "A", "Y", "03-01-2024"},
{"4", "B", "X", "04-01-2024"},
{"5", "B", "X", "05-01-2024"}
},
{"Index", "ID", "Group A", "Extract Date"}
),
ChangedType = Table.TransformColumnTypes(Source, {
{"Index", Int64.Type}, {"ID", type text},
{"Group A", type text}, {"Extract Date", type date}
}),
AddedRowNumber = Table.AddIndexColumn(ChangedType, "RowNumber", 0, 1, Int64.Type),
PrevRows = Table.AddIndexColumn(ChangedType, "RowNumber", 1, 1, Int64.Type),
RenamedPrev = Table.RenameColumns(PrevRows, {
{"Index", "Prev_Index"},
{"ID", "Prev_ID"},
{"Group A", "Prev_Group A"},
{"Extract Date", "Prev_Extract Date"}
}),
Merged = Table.NestedJoin(AddedRowNumber, {"RowNumber"}, RenamedPrev, {"RowNumber"}, "PrevRow", JoinKind.LeftOuter),
Expanded = Table.ExpandTableColumn(Merged, "PrevRow", {
"Prev_Index", "Prev_ID", "Prev_Group A", "Prev_Extract Date"
}),
AddedIndexPlus1 = Table.AddColumn(Expanded, "Row-1_IndexPlus1", each if [Prev_Index] <> null then [Prev_Index] + 1 else null, Int64.Type),
AddedConditional = Table.AddColumn(AddedIndexPlus1, "Conditional Extract Date", each
if [Prev_ID] = [ID] and [Prev_Group A] = [Group A] then [Prev_Extract Date] else null, type nullable date),
#"Sorted Rows" = Table.Sort(AddedConditional,{{"Index", Order.Ascending}})
in
#"Sorted Rows"
Some best practices to keep in mind while implementing multi-row logic in Power Query:
Filter and remove unnecessary columns early to optimize performance
Use Table.Buffer for small lookup tables before merges, if reused
Clean and standardize key columns before joining
Perform merges and sorts later in the query chain when possible
Here are some resources which you might find useful:
Power Query - Methods to Refer to Previous Row - T... - Microsoft Fabric Community
Best practices when working with Power Query - Power Query | Microsoft Learn
Hope this helps. Please reach out for further assistance.
If this post helps, then please consider to Accept as the solution to help the other members find it more quickly.
Thank you.
Please find the attached .pbix file for reference.
Hi @nidish ,
Just wanted to check if the response provided was helpful. If yes, please consider marking it as "Accepted Solution" to assist others with similar queries. If further assistance is needed, please reach out.
Thank you.
Hi @nidish Use Table.AddIndexColumn to add indices and Table.Buffer to reference previous rows. For formulas like [Row-1:Index]+1, create an index column and add 1 to shift values. For conditional logic, use if...then...else with buffered tables to compare and derive values from prior rows. Break complex workflows into smaller steps for clarity and performance.
User | Count |
---|---|
77 | |
75 | |
46 | |
31 | |
28 |
User | Count |
---|---|
99 | |
93 | |
50 | |
49 | |
46 |