Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I have a problem with non-listed values in a table. I have a standard timeDimension and a table with orders:
Order Date | Article Number | Stock | Ordered Amount |
01.02.2021 | 12 | 200 | 20 |
02.02.2021 | 12 | 180 | 50 |
05.02.2021 | 12 | 130 | 10 |
06.02.2021 | 12 | 120 | 30 |
As you can see there are no orders on 03.02.2021 and 04.02.2021. What I need is this:
Order Date | Article Number | Stock | Ordered Amount |
01.02.2021 | 12 | 200 | 20 |
02.02.2021 | 12 | 180 | 50 |
03.02.2021 | 12 | 130 | 0 |
04.02.2021 | 12 | 130 | 0 |
05.02.2021 | 12 | 130 | 10 |
06.02.2021 | 12 | 120 | 30 |
It is way more complicated than it seems.
I am open to any solutions, whether with M, Dax, or a new table structure.
Thanks for your help!
Solved! Go to Solution.
@Anonymous
Here is one way. First the model:
now create the following measures:
1) Simple sums for stock and orders
2) The initial stock for an article:
Starting stock =
VAR StartDate =
CALCULATE (
FIRSTDATE ( 'Date Table'[Date] ),
ALLEXCEPT ( FactTable, FactTable[Article Number] )
)
RETURN
CALCULATE (
[Sum of Stock],
FILTER ( ALL ( 'Date Table' ), 'Date Table'[Date] = StartDate )
)
3) the cumulative orders:
Cumulative Orders =
CALCULATE (
[Sum of order],
FILTER (
ALL ( 'Date Table' ),
'Date Table'[Date] <= MAX ( 'Date Table'[Date] )
)
)
4) the running stock value:
Running Stock =
CALCULATE (
[Starting stock] - [Cumulative Orders],
DATEADD ( 'Date Table'[Date], -1, DAY )
)
all of which are seen in the following table:
and finally delete the unnecessary fields from the visual:
(if you'd rather see 0 instead of blanks for sum of orders, simply add a 0 in the measure):
Sum of order = SUM(FactTable[Ordered Amount]) + 0
I've attached the sample PBIX for your reference
Proud to be a Super User!
Paul on Linkedin.
Hi@Anonymous,
Best Regards,
Caitlyn Yan
Suppose you are looking for a running total?
File is attached.
Kind regards, Steve.
Proud to be a Super User!
Awesome Keyboard Shortcusts in Power BI, thumbs up if you like the article
My Community Blog Articles (check them out!)
My Blog - Power M code to automatically detect column types -
How to create test data using DAX!
@Anonymous
Here is one way. First the model:
now create the following measures:
1) Simple sums for stock and orders
2) The initial stock for an article:
Starting stock =
VAR StartDate =
CALCULATE (
FIRSTDATE ( 'Date Table'[Date] ),
ALLEXCEPT ( FactTable, FactTable[Article Number] )
)
RETURN
CALCULATE (
[Sum of Stock],
FILTER ( ALL ( 'Date Table' ), 'Date Table'[Date] = StartDate )
)
3) the cumulative orders:
Cumulative Orders =
CALCULATE (
[Sum of order],
FILTER (
ALL ( 'Date Table' ),
'Date Table'[Date] <= MAX ( 'Date Table'[Date] )
)
)
4) the running stock value:
Running Stock =
CALCULATE (
[Starting stock] - [Cumulative Orders],
DATEADD ( 'Date Table'[Date], -1, DAY )
)
all of which are seen in the following table:
and finally delete the unnecessary fields from the visual:
(if you'd rather see 0 instead of blanks for sum of orders, simply add a 0 in the measure):
Sum of order = SUM(FactTable[Ordered Amount]) + 0
I've attached the sample PBIX for your reference
Proud to be a Super User!
Paul on Linkedin.
Thank you PaulDBrown! This was what I needed! Had to change some little things but all in all thats it!
Hi @Anonymous ,
Create a measure to display your [Ordered Amount] value like this:
_yourAmount = SUM(yourTable[Ordered Amount]) + 0
This will show you zeroes where no other value exists.
If you don't want the zeroes, you can right-click on any of your displayed dimensions and check 'Show items with no data':
However, note that this will show ALL values available in the dimensions, so may not be suitable for your use-case.
Pete
Proud to be a Datanaut!
Hi Pete,
Thanks for your reply, but unfortunately this isn't what I need.
Selecting "Show items with no data" leaves all values empty except the date.
The measure just adds rows with same date as order date but with zeros.
lh_2020
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 |
---|---|
64 | |
56 | |
54 | |
36 | |
34 |
User | Count |
---|---|
85 | |
73 | |
55 | |
45 | |
43 |