Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello, all
I have a question that I need your help to solve.
What I have:
I have a dataset where I run a query everyday to get todays stock. I also have planned future consumption per day, and I have planned refills to the stock. See table below for example.
What I want to create:
I want to create a column that show total stocks per day ("Total stock" in yellow), which is based on todays stock, planned refills and consumption per day.
(Because I run the query for todays stock everyday, I want the table to allways start on todays date)
In excel I would have solved it like this, where "Total stock" for today (in cell E2) is calculated: B2+C2-D2,
For tomorrow (E3): E2+C3-D3
For the day after (E4): E3+C4-D4
And so on:
Any suggestions on how to achieve this?
Thank you, I'm really grateful for all help 🙂
Solved! Go to Solution.
As I understand it, this is a running total of three columns. Here are two calculated columns. You can try both and use the more performant one.
Total Stock =
VAR vDate = Table1[Date]
VAR vResult =
CALCULATE (
SUM ( Table1[Todays stock] )
+ SUM ( Table1[Planned refill] )
- SUM ( Table1[Consumption per day] ),
ALL ( Table1 ),
Table1[Date] <= vDate
)
RETURN
vResult
Total Stock SUMX =
VAR vDate = Table1[Date]
VAR vTable = FILTER ( Table1, Table1[Date] <= vDate )
VAR vResult =
SUMX ( vTable,
Table1[Todays stock]
+ Table1[Planned refill]
- Table1[Consumption per day]
)
RETURN
vResult
Proud to be a Super User!
As I understand it, this is a running total of three columns. Here are two calculated columns. You can try both and use the more performant one.
Total Stock =
VAR vDate = Table1[Date]
VAR vResult =
CALCULATE (
SUM ( Table1[Todays stock] )
+ SUM ( Table1[Planned refill] )
- SUM ( Table1[Consumption per day] ),
ALL ( Table1 ),
Table1[Date] <= vDate
)
RETURN
vResult
Total Stock SUMX =
VAR vDate = Table1[Date]
VAR vTable = FILTER ( Table1, Table1[Date] <= vDate )
VAR vResult =
SUMX ( vTable,
Table1[Todays stock]
+ Table1[Planned refill]
- Table1[Consumption per day]
)
RETURN
vResult
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
96 | |
80 | |
67 | |
62 |
User | Count |
---|---|
137 | |
106 | |
104 | |
81 | |
63 |