Forum Discussion
Rolling Stock Position With Gaps In Months
- 2 years ago
Anonymous,
This can be solved with a date table. There are various ways to create a date table--here's a DAX calculated table:
Date = ADDCOLUMNS ( CALENDARAUTO (), "Month Start Date", DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 1 ) )Create a 1:* relationship between the date table and data (fact) table:
Create measures:
Sum of Stock Value = SUM ( 'Table'[Stock Value] )Running Total = CALCULATE ( [Sum of Stock Value], FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) ) )Result:
Whenever possible, use dimension table fields in visuals (e.g., 'Date'[Month Start Date]).
Close but doesn't address if the table is missing data.
Let's say I've created a date table for 01/01 - 31/12 and connected it to the stock table. If I drag in the date table date column, the measure would be blank for 02/01, 03/01 etc.. when actually the stock position as of 03/01 would still be 10 not blank.
Edited with clearer expected results
Hi Anonymous ,
I'm sorry that Power BI doesn't have such a smart feature at the moment, and the requirement that you mentioned that an undisplayed date still needs to be returned to the previous value can't be realized yet.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous2 years agoNot applicable
No problem, thank you so much for your help