Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello,
I have this scenario:
I currently have a measure that I know is incorrect but I cannot figure out how to write it to bring the desired result.
Current Measure:
-If next period does not have any records for that Material, carry forward previous period's ending total
-Else If the next period does have records for that Material, then take the value from the next period with the highest primary key for that Material
So in the example above, Oct in 2022 should be sum of Product A's value [11,502.54] + Product B's value from September [1080.27] = 12,582.81. This value should be carried forward "forever" since there are no more records for either Material.
I hope this made sense - I feel like the solution is out there and I have been looking at this for too long!
TIA
Solved! Go to Solution.
Hi @Anonymous ,
Here are the steps you can follow:
1. Create measure.
Rank_Measure =
var _rank=
RANKX(FILTER(ALL('Table'),'Table'[Material]=MAX('Table'[Material])),CALCULATE(SUM([Del/finish])),,ASC)
var _if=
IF(
MAX('Table'[Prikey])=MAXX(FILTER(ALL('Table'),'Table'[Material]=MAX('Table'[Material])),[Prikey])&&_rank=
MAXX(FILTER(ALL('Table'),'Table'[Material]=MAX('Table'[Material])),_rank),1,0)
return
_ifRunning Total Highest Primkey MEASURE =
SUMX(FILTER(ALL('Table'),
[Rank_Measure]=1),[Running Total Highest Primkey Calc Column])
2. Result:
If you need pbix, please click here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @Anonymous ,
Here are the steps you can follow:
1. Create measure.
Rank_Measure =
var _rank=
RANKX(FILTER(ALL('Table'),'Table'[Material]=MAX('Table'[Material])),CALCULATE(SUM([Del/finish])),,ASC)
var _if=
IF(
MAX('Table'[Prikey])=MAXX(FILTER(ALL('Table'),'Table'[Material]=MAX('Table'[Material])),[Prikey])&&_rank=
MAXX(FILTER(ALL('Table'),'Table'[Material]=MAX('Table'[Material])),_rank),1,0)
return
_ifRunning Total Highest Primkey MEASURE =
SUMX(FILTER(ALL('Table'),
[Rank_Measure]=1),[Running Total Highest Primkey Calc Column])
2. Result:
If you need pbix, please click here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
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!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 9 | |
| 6 | |
| 5 |
| User | Count |
|---|---|
| 27 | |
| 22 | |
| 19 | |
| 17 | |
| 11 |