The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hai All,
Question: Need solution in both M-QUERY and DAX to get the previous row value into a new column.
The below table represents a sample data representing the price for the corresponding Dates.
Pcd-Price for current date
ppdr-Price for previous date reference.
ppd-price for previous date
Here we considered the data which is from date 10 to 19(refer above table).
For Example
Solved! Go to Solution.
Hi @Anonymous
If you column [S.No] is like Index, use this column, otherwise add an index column, M here
Table.AddColumn(#"Changed Type", "ppd_M", each #"Changed Type"[pcd]{[S.No]}?)
DAX here
ppd_DAX =
VAR CurNo = 'Table'[S.No]
RETURN
CALCULATE(VALUES('Table'[pcd]),FILTER(ALL('Table'),'Table'[S.No]=CurNo+1))
Hi @Anonymous
If you column [S.No] is like Index, use this column, otherwise add an index column, M here
Table.AddColumn(#"Changed Type", "ppd_M", each #"Changed Type"[pcd]{[S.No]}?)
DAX here
ppd_DAX =
VAR CurNo = 'Table'[S.No]
RETURN
CALCULATE(VALUES('Table'[pcd]),FILTER(ALL('Table'),'Table'[S.No]=CurNo+1))