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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Filter Stock with date

Hello everyone ! 

 

I did a SQL query to get stock of my articles and documents affecting the stock (purchase order and supplier). However I need to know the stock on a given date, when I use the power bi filter, this one directly removes the items if there is no document on my date.

 

Have you some idea what i can do ? 

 

Example with AUSONNE - 63.1.152SC PAR 10/BOITE : 

 

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Suppose the original table structure is similar to below:

1.PNG

 

As there is no corresponding record for AUSONNE - 63.1.152SC PAR 10/BOITE on '2017-01-01' and '2017-01-02', if we choose date range between '2017-01-03' and '2017-01-04' from slicer, of course, it will remove the items if there is no document (here is AUSONNE - 63.1.152SC PAR 10/BOITE).

 

To work around this, we can try to create a new calculated table in two steps.

Stock_1 =
ADDCOLUMNS (
    CROSSJOIN ( VALUES ( Stock[DOC_DT_PRV] ), VALUES ( Stock[LIG_LIB] ) ),
    "Stock", 0
)

 

Stock_2 = UNION(Stock,Stock_1)

 2.PNG

 

Then, drag corresponding fileds from 'Stock_2' into Matrix and slicer.

3.PNG

 

However, if your table structure is like below, you can first Pivot it in Query Editor mode, in order to get a new structure same as above. Alternatively, if you don't want to pivot table, you only need to make a little adjustment to above formulas, the logic is the same. Please refer to the .pbix file for more details.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Suppose the original table structure is similar to below:

1.PNG

 

As there is no corresponding record for AUSONNE - 63.1.152SC PAR 10/BOITE on '2017-01-01' and '2017-01-02', if we choose date range between '2017-01-03' and '2017-01-04' from slicer, of course, it will remove the items if there is no document (here is AUSONNE - 63.1.152SC PAR 10/BOITE).

 

To work around this, we can try to create a new calculated table in two steps.

Stock_1 =
ADDCOLUMNS (
    CROSSJOIN ( VALUES ( Stock[DOC_DT_PRV] ), VALUES ( Stock[LIG_LIB] ) ),
    "Stock", 0
)

 

Stock_2 = UNION(Stock,Stock_1)

 2.PNG

 

Then, drag corresponding fileds from 'Stock_2' into Matrix and slicer.

3.PNG

 

However, if your table structure is like below, you can first Pivot it in Query Editor mode, in order to get a new structure same as above. Alternatively, if you don't want to pivot table, you only need to make a little adjustment to above formulas, the logic is the same. Please refer to the .pbix file for more details.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.