Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi Guys
How do I get previous value from last month into a new column?
| Date | Cumulative Sales | Previous Month **bleep** Sales |
| 01/06/2018 | 10 | 0 |
| 01/07/2018 | 20 | 10 |
| 01/08/2018 | 30 | 20 |
Solved! Go to Solution.
@KH11NDR here you go. Use the PARALLELPERIOD function to get the desired result.
@KH11NDR Can you post screenshot of the final table where you are testing the solution, the list of values which go in it. Also are you using a calculated column or measure. I am using a measure.
Hi @KH11NDR, In order to achive Lag(previous value) you need to follow below steps.
Create two index column one starts with 0 name it as Index0 and other starts with 1 name it as Index1
Do left Join on same table on condition will be Maintable.Index0 = SelfJoinTable.Index1.
Expand the column and select the "previous value" column which will be ur Lag column.
Sample query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkrMKlXSUTI0MlaK1QFxc0FcEzMzMNc7sygxD8g3UoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Rank = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Rank", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
#"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 1, 1),
#"Merged Queries" = Table.NestedJoin(#"Added Index1",{"Index"},#"Added Index1",{"Index.1"},"Added Index1",JoinKind.LeftOuter),
#"Expanded Added Index1" = Table.ExpandTableColumn(#"Merged Queries", "Added Index1", {"Rank"}, {"Lag.Rank"}),
#"Sorted Rows" = Table.Sort(#"Expanded Added Index1",{{"Index", Order.Ascending}}),
#"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index", "Index.1"})
in
#"Removed Columns"
Output screesnshot:
And finally replace null with zero.
Hope above solution will help in your case.
Did I answer your question? Mark my post as a solution!
Suman152
There ha to be an easier way for sure? Thanks Suman, but Power BI, Must have an easier way,.
@KH11NDR here you go. Use the PARALLELPERIOD function to get the desired result.
@Anonymous
I'm still not getting any figures, I've added my date to a master calendar too.
@KH11NDR Check the format of the date field? The data set I used is pretty simple and straight forward. Here is a snap of my model. Could you send screenshots of your model, your calculations and final results.
Previous month = CALCULATE(SUM(Merge1[Cumulative Revenue]),PARALLELPERIOD(Merge1[Date],-1,MONTH))
@KH11NDR Can you post screenshot of the final table where you are testing the solution, the list of values which go in it. Also are you using a calculated column or measure. I am using a measure.
Changed it from Column to Measure and workd like a treat.
Thanks
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!