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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I need a help with calculate the difference between 2 dates, for example:
I have this Table:
| Periods | Value A | Value B | %Value B |
| Week 1 | 680 | 475 | 69,85% |
| Week 2 | 677 | 466 | 68,83% |
| Week 3 | 640 | 438 | 68,44% |
| Week 4 | 646 | 457 | 70,74% |
And I need a colunm or a measure "Difference" that calculate de difference of colunm "%Value B" by Periods:
| Periods | Value A | Value B | %Value B | Difference |
| Week 1 | 680 | 475 | 69,85% | |
| Week 2 | 677 | 466 | 68,83% | -1,02% |
| Week 3 | 640 | 438 | 68,44% | -0,39% |
| Week 4 | 646 | 457 | 70,74% | 2,30% |
Anybody can help me?
tks.
Solved! Go to Solution.
@Anonymous Add an Index column in Power Query Editor or a Sequential week column like this: Sequential - Microsoft Power BI Community. Then you can use the MTBF pattern. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous
@Anonymous Add an Index column in Power Query Editor or a Sequential week column like this: Sequential - Microsoft Power BI Community. Then you can use the MTBF pattern. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous
thanks for your help, but I dont understand the first pass:
"VAR __Current = [Value]"
This [Value] is the sum of Value B?
tks
@Anonymous In your case yes. The code is generic code, you have to adapt it to your particular table name and column names.
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 |
|---|---|
| 21 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 35 | |
| 31 | |
| 19 | |
| 13 | |
| 10 |