Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Filling balance for missing days

Hello

I'm new in DAX and in this forum, sorry if something wrong.

I have such table with balance by SKU

s1.jpg

 

I've created matrix visual and the task is to show last actual balance even if there're no records in source table for that date.

s2.jpg

 

In my example it should be 30 for SKU1 at 02.03.19 and 20 for SKU2 at 03.03.19

 

Thanks in advance.

2 ACCEPTED SOLUTIONS
PattemManohar
Community Champion
Community Champion

@Anonymous Create a new table as below and use this table for your Matrix visual

 

Test267Out = UNION(
                    SELECTCOLUMNS(
                                    EXCEPT(
                                            CROSSJOIN(VALUES(Test267MatrixBlankZero[Date]),VALUES(Test267MatrixBlankZero[SKU]))
                                           ,SELECTCOLUMNS(Test267MatrixBlankZero,"Date",[Date],"SKU",[SKU])
                                          )
                                 ,"Date",[Date],"SKU",[SKU],"Qty",0
                                 )
                  ,Test267MatrixBlankZero
                    )

Here is the screenshot of both actual (using the source table) and expected (using the above new calculated table)

 

image.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

@Anonymous  Please add an another column to the new table that was created as above

 

NewQty = 
VAR _PrevDate = CALCULATE(MAX([Date]),FILTER(Test267Out,Test267Out[SKU]=EARLIER(Test267Out[SKU]) && Test267Out[Date]<EARLIER(Test267Out[Date]) && Test267Out[Qty] <> 0))
VAR _Lkp = LOOKUPVALUE(Test267Out[Qty],Test267Out[SKU],Test267Out[SKU],Test267Out[Date],_PrevDate)
RETURN IF(ISBLANK(_Lkp),Test267Out[Qty],_Lkp)

image.pngimage.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

5 REPLIES 5
PattemManohar
Community Champion
Community Champion

@Anonymous Create a new table as below and use this table for your Matrix visual

 

Test267Out = UNION(
                    SELECTCOLUMNS(
                                    EXCEPT(
                                            CROSSJOIN(VALUES(Test267MatrixBlankZero[Date]),VALUES(Test267MatrixBlankZero[SKU]))
                                           ,SELECTCOLUMNS(Test267MatrixBlankZero,"Date",[Date],"SKU",[SKU])
                                          )
                                 ,"Date",[Date],"SKU",[SKU],"Qty",0
                                 )
                  ,Test267MatrixBlankZero
                    )

Here is the screenshot of both actual (using the source table) and expected (using the above new calculated table)

 

image.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

Hi  @PattemManohar 

Thank you, I feel that it is aslmost solution.

But which measure or condition should I use to get Quantity at previous non blank date value instead zeroes?

s4.jpg

 

First I wanted to add CALCULATE instead zero, but got blank:

s3.jpg

@Anonymous  Please add an another column to the new table that was created as above

 

NewQty = 
VAR _PrevDate = CALCULATE(MAX([Date]),FILTER(Test267Out,Test267Out[SKU]=EARLIER(Test267Out[SKU]) && Test267Out[Date]<EARLIER(Test267Out[Date]) && Test267Out[Qty] <> 0))
VAR _Lkp = LOOKUPVALUE(Test267Out[Qty],Test267Out[SKU],Test267Out[SKU],Test267Out[Date],_PrevDate)
RETURN IF(ISBLANK(_Lkp),Test267Out[Qty],_Lkp)

image.pngimage.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

Hello @PattemManohar 

Thank you, that's exactly what I needed!

Whith little change 

Test267Out[Date]<=EARLIER(Test267Out[Date])

instead of 

Test267Out[Date]<EARLIER(Test267Out[Date])

 Many thanks!

adityavighne
Continued Contributor
Continued Contributor

create Measure of Quantity

 

Measure_Count = COUNT([Quantity])+0

 

and use this measure in matrix

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.