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

Finding lost orders in a calculated column

Hi!

 

I am having trouble writing a DAX formula for a calculated column. In summary, my organization recieves a ton of orders everyday from different customers. It is possible that an order can be "open" for a few days before stock is confirmed and the order is shipped. Sometimes an order is dropped in the system which could happen for a variety of reasons. I am trying to track these orders that are dropped. Currently, I have a formula that works and uses the TODAY() function. I would like to use a new formula that eliminates the use of TODAY() so I can track historicals and weekly averages. An example of what I am looking for is below.

 

DATEORDER IDLOST ORDER CHECK
1/11230
1/14561
1/17890
1/21230
1/27890

 

I would like a 1 registered next to order 456 since it does not appear on 1/2, but appeared on 1/1. I would appreciate any help! Unfortunately, I cannot share any data as it is highly confidential. And again, I would like to eliminate my use of the TODAY() function, thanks in advance!

 

 

1 ACCEPTED SOLUTION

You may probably try:

LOST ORDER =
  VAR __OrderID = [ORDER ID]
  VAR __Date = [DATE]
  VAR __Table = FILTER('Table',[DATE] = __Date + 1.)
RETURN
  SWITCH(TRUE(),
    __Date = TODAY(),0,
    __OrderID IN SELECTCOLUMNS(__Table,"OrderID",[ORDER ID]),0,
    1
  )



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

Well, perhaps something like this:

 

LOST ORDER =
  VAR __OrderID = [ORDER ID]
  VAR __Date = [DATE]
  VAR __Table = FILTER('Table',[DATE] = __Date + 1.)
RETURN
  IF(__OrderID IN SELECTCOLUMNS(__Table,"OrderID",[ORDER ID]),0,1)

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Seems as if this is working! Thank you very much!!! One more thing - it registers a 1 for all of today's order since there is no entries for tomorrow. Is it possible to manipulate this formula to exclude 1's from today's date? Thank you!!

 

You may probably try:

LOST ORDER =
  VAR __OrderID = [ORDER ID]
  VAR __Date = [DATE]
  VAR __Table = FILTER('Table',[DATE] = __Date + 1.)
RETURN
  SWITCH(TRUE(),
    __Date = TODAY(),0,
    __OrderID IN SELECTCOLUMNS(__Table,"OrderID",[ORDER ID]),0,
    1
  )



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

This is a huge help ... thank you very much!!! One last request if you have the time - can we exclude the last day of each month in the calculation? Orders every month get piled up until a new month where everything resets. So right now it is showing that I lose all of my orders at the beginning of each beginning of month / rest. Thank you again!!

 

Let's see...

LOST ORDER =
  VAR __OrderID = [ORDER ID]
  VAR __Date = [DATE]
  VAR __Table = FILTER('Table',[DATE] = __Date + 1.)
RETURN
  SWITCH(TRUE(),
    __Date = TODAY(),0,
    __Date = EOMONTH(__Date,0),0,
    __OrderID IN SELECTCOLUMNS(__Table,"OrderID",[ORDER ID]),0,
    1
  )

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.