Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi all,
I understand that this is probably a specific issue to myself, however if you have time to assist that would be greatly appreciated!
Currently I have a 4 tables in my Power Bi:
From this, I want to replicate a formula from Excel that looks something like this -
"Current Weeks CarsOnHand" - "Previous Weeks CarsOnHand" + "Previous Weeks CarsCounted" (screenshot attached)
What would be my best way to approach this in Power Bi? I feel like I have all the right information for it to be achieved, just having some troubles with executing it.
Any help is appreciated.
Solved! Go to Solution.
Hi @clock0928 ,
I will start by showing you my test data:
To make it easier to see, I created a week table and used that to create a slicer:
I then used DAX to create the following three measures:
Total_CarsOnHand =
CALCULATE(
SUM('Work On Hand'[CarsOnHand]),
FILTER(
ALLSELECTED('Calendar'[WeekOfYear]),
'Calendar'[WeekOfYear] = SELECTEDVALUE('Slicer'[WeekNo])
)
)
LastWeek_Total_CarsOnHand =
CALCULATE(
SUM('Work On Hand'[CarsOnHand]),
'Calendar'[WeekOfYear] = SELECTEDVALUE('Slicer'[WeekNo]) - 1, ALL('Calendar')
)
LastWeek_Total_CarsCounted =
CALCULATE(
SUM('Daily Statistics'[CarsCounted]),
'Calendar'[WeekOfYear] = SELECTEDVALUE('Slicer'[WeekNo]) - 1, ALL('Calendar')
)
The three measures can then be used to perform the calculation steps you require:
Measure = 'Work On Hand'[Total_CarsOnHand] - 'Work On Hand'[LastWeek_Total_CarsOnHand] + 'Daily Statistics'[LastWeek_Total_CarsCounted]
The final result is shown below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is fantastic, thank you @Anonymous !
Is there a way to have the filter based on my calendar table if I already have a field of "WeekOfYear"?
Hi @clock0928,
Of course you can, just change the
SELECTEDVALUE('Slicer'[WeekNo])
into
SELECTEDVALUE('Calendar'[WeekOfYear])
in the three DAXs, and I've tested them and they still work fine in my sample data.
Best Regards,
Dino Tao
@Anonymous love your work - thank you again for the assistance 🙂
Hi @clock0928 ,
I will start by showing you my test data:
To make it easier to see, I created a week table and used that to create a slicer:
I then used DAX to create the following three measures:
Total_CarsOnHand =
CALCULATE(
SUM('Work On Hand'[CarsOnHand]),
FILTER(
ALLSELECTED('Calendar'[WeekOfYear]),
'Calendar'[WeekOfYear] = SELECTEDVALUE('Slicer'[WeekNo])
)
)
LastWeek_Total_CarsOnHand =
CALCULATE(
SUM('Work On Hand'[CarsOnHand]),
'Calendar'[WeekOfYear] = SELECTEDVALUE('Slicer'[WeekNo]) - 1, ALL('Calendar')
)
LastWeek_Total_CarsCounted =
CALCULATE(
SUM('Daily Statistics'[CarsCounted]),
'Calendar'[WeekOfYear] = SELECTEDVALUE('Slicer'[WeekNo]) - 1, ALL('Calendar')
)
The three measures can then be used to perform the calculation steps you require:
Measure = 'Work On Hand'[Total_CarsOnHand] - 'Work On Hand'[LastWeek_Total_CarsOnHand] + 'Daily Statistics'[LastWeek_Total_CarsCounted]
The final result is shown below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |