Forum Discussion
Can't show values under all Date Columns?! Help Please
- 10 years ago
If there are no incoming deliveries, the product data will not exist for that week in your dataset, right?
In following test dataset, there is no incoming deliveries for “-62901” on 3/14, 3/28, 3/29 and 4/4.
We can first create a new table with following formula. Relate this new table with stock table using product.
FullTable = GENERATE ( SUMMARIZECOLUMNS ( Table2[Product] ), SUMMARIZECOLUMNS ( Table2[Date] ) )Then create WeekNum column and Quantity column in this new table.
WeekNum = WEEKNUM ( FullTable[Date] )
Quantity = CALCULATE ( SUM ( Table2[Quantity] ), FILTER ( Table2, Table2[Date] = FullTable[Date] && Table2[Product] = FullTable[Product] ) )At last, create a measure with following formula. I’ve also upload my .pbix file here for reference.
LastNoBlankTotal = VAR LastNoBlankWeek = CALCULATE ( MAX ( FullTable[WeekNum] ), FILTER ( ALL ( FullTable ), FullTable[WeekNum] < MAX ( FullTable[WeekNum] ) && FullTable[Quantity] <> BLANK () ), VALUES ( Table1[stp_product] ) ) RETURN ( IF ( [Incoming Qty] = BLANK (), [Stock Qty] + CALCULATE ( [Incoming Qty], FullTable[WeekNum] = LastNoBlankWeek ), [Rolling Total] ) )Best Regards,
Herbert
Yes that's exactly what I would like to do!
My measures are just a SUM of the original value - I don't know whether this was necessary but in my mind made them easier to work with.
Thank you Herbert,
J
If there are no incoming deliveries, the product data will not exist for that week in your dataset, right?
In following test dataset, there is no incoming deliveries for “-62901” on 3/14, 3/28, 3/29 and 4/4.
We can first create a new table with following formula. Relate this new table with stock table using product.
FullTable =
GENERATE (
SUMMARIZECOLUMNS ( Table2[Product] ),
SUMMARIZECOLUMNS ( Table2[Date] )
)Then create WeekNum column and Quantity column in this new table.
WeekNum = WEEKNUM ( FullTable[Date] )
Quantity =
CALCULATE (
SUM ( Table2[Quantity] ),
FILTER (
Table2,
Table2[Date] = FullTable[Date]
&& Table2[Product] = FullTable[Product]
)
)At last, create a measure with following formula. I’ve also upload my .pbix file here for reference.
LastNoBlankTotal =
VAR LastNoBlankWeek =
CALCULATE (
MAX ( FullTable[WeekNum] ),
FILTER (
ALL ( FullTable ),
FullTable[WeekNum] < MAX ( FullTable[WeekNum] )
&& FullTable[Quantity] <> BLANK ()
),
VALUES ( Table1[stp_product] )
)
RETURN
(
IF (
[Incoming Qty] = BLANK (),
[Stock Qty]
+ CALCULATE ( [Incoming Qty], FullTable[WeekNum] = LastNoBlankWeek ),
[Rolling Total]
)
)
Best Regards,
Herbert
- J_R_Cribb10 years ago
Helper I
Hi Herbert,
Thank you for detailing this perfectly - I've tried and tested for all products that I have data for (100+) and it gives me a running total which I couldn't achieve before.
If I filter from a certain date, say Week 33 for instance, would it only take into account future data points?
I also have a third table giving descriptions for each product code, which is linked to both data tables. Whenever I have tried to include the description in the table it either crashes or just does not work - is this perhaps a memory issue due to the vast number of calculations that BI needs to do?
Thank you again,
J
- J_R_Cribb10 years ago
Helper I
Please could you provide an explanation on how your formulae for LastNoBlankWeek & LastNoBlankTotal operate?
Thank you,J