Skip to main content

Power BI

Needs Votes

DAX function to create column with shifted rows

Vote (2) Share
Power BI User's profile image

Power BI User on 02 Apr 2020 18:22:14

Create a DAX function that reads a given column, then creates a new column where the contents of each row in the original column are shifted n times above/below in the new column. This can be used for previous sales entries or moving range charts.

I have noticed there are many creative ways of achieving this in DAX (it must be DAX as this is needed for calculated columns) online, but most of these methods are quite resource hungry. Having an established method from you guys will help many in the Power BI community.

Big up to Power BI - I love it!

Comments (1)
Power BI User's profile image Profile Picture

Joshua Chartier on 06 Jul 2020 00:17:23

RE: DAX function to create column with shifted rows

I've created a proposal for adding ordered iterators in DAX. I think they could be used to get the shifts you're asking for.
https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/40647124-ordered-iterators