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

stock calculation based on the next day

I've a table stock, when the product exists in my stock for a date, so it'll exist in the table as a new row

 

dateproduct
02/02/2022sundae
05/02/2022sundae

 

When the user select for example date filter from 01/02 till 07/02, I'd like to show 

dateproductstock
01/02/2022sundae1
02/02/2022sundae1
03/02/2022sundae0
04/02/2022sundae1
05/02/2022sundae1
06/02/2022sundae0
07/02/2022sundae0


For example, for 04/02, I need to look for whether it exists(next day) on 05/02 and as we see that it exists, we display 1 for 04/02. 
For example, for 06/02, I need to look for whether it exists(next day) on 07/02 and as we see that it does not exist, we display 0 for 06/02. 

For example, for 01/02, I need to look for whether it exists(next day) on 02/02 and as we see that it exists, we display 1 for 01/02. 

 

Any idea please?

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please refer to my pbix filw to see if it helps you.

Create a column first in the first table.

edate_ = 'Table'[date]-1

Then create a measure.

Measure =
VAR _maxdate =
    MAX ( 'Table'[date] ) - 1
RETURN
    IF (
        MAX ( 'Table (2)'[date] )
            IN VALUES ( 'Table'[date] )
                || MAX ( 'Table (2)'[date] ) IN VALUES ( 'Table'[edate_] ),
        1,
        0
    )

vpollymsft_0-1653894879237.png

 

 Best Regards
Community Support Team _ Polly

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

Please refer to my pbix filw to see if it helps you.

Create a column first in the first table.

edate_ = 'Table'[date]-1

Then create a measure.

Measure =
VAR _maxdate =
    MAX ( 'Table'[date] ) - 1
RETURN
    IF (
        MAX ( 'Table (2)'[date] )
            IN VALUES ( 'Table'[date] )
                || MAX ( 'Table (2)'[date] ) IN VALUES ( 'Table'[edate_] ),
        1,
        0
    )

vpollymsft_0-1653894879237.png

 

 Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tamerj1
Super User
Super User

Hi @Anonymous 
What about 05/02?

Anonymous
Not applicable

@tamerj1  for 05/02, I 'll check if the product exists in the table stock for this date 05/02, it exists, so I need to display 1.

 

Please let me know if you need more details, thank you very much

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.