Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I have one Table with 3 columns in PowerBI. I am trying to make a calculated column - "PrevNumber"

PrevUniqueID will always have a match in the UniqueID column of a different Row.
Goal is to pull the Number column/value for whichever Row has a UniqueID that matches the PrevUniqueID.
I am trying this formula:

Any ideas?
Solved! Go to Solution.
Hi @Anonymous ,
Try this code to create a calculated column.
PreviousMonthNumber =
VAR _PreMonthUniqueID =
CALCULATE (
SUM ( 'Table'[Number] ),
FILTER ( 'Table', 'Table'[UniqueID] = EARLIER ( 'Table'[PreMonthUniqueID] ) )
)
RETURN
_PreMonthUniqueID + 0
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Try this code to create a calculated column.
PreviousMonthNumber =
VAR _PreMonthUniqueID =
CALCULATE (
SUM ( 'Table'[Number] ),
FILTER ( 'Table', 'Table'[UniqueID] = EARLIER ( 'Table'[PreMonthUniqueID] ) )
)
RETURN
_PreMonthUniqueID + 0
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey there,
EnterpriseDNA has a great writeup on how to achieve this, you can check it out here: https://forum.enterprisedna.co/t/previous-row-value/9789
@sirlanceohlott thanks for the response!
I had been thinking maybe I need indexing.
I thought I could get around it if I could just figure out why the formula is essentially pulling backwards (Dec 2021 is pulling from Jan 2022, instead of having Jan 2022 pulling from Dec 2021). but maybe indexing is really the only answer..
@Anonymous you're welcome!
Yeah, I know it's a little frustrating, but I believe the indexing will help with what you are trying to achieve. I've had similar challenges where indexing was one of the ways to get it functioning as I intended.
Best of luck as you continue on, others might have some different solutions too!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 46 | |
| 43 | |
| 39 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 65 | |
| 31 | |
| 28 | |
| 24 |