Forum Discussion

Cadenze's avatar
Cadenze
Helper II
3 years ago
Solved

How to count posts for dates before yesterday while transdate is fixed

I log invoice data every day, and would like to count the number of invoices that were issued before yesterday for orders that were confirmed for yesterday. I.e. the number of orders that were due yesterday and were shipped before yesterday.

I have searched the forum and found something like this:

 
Shipped early =
countrows(filter(DeliveryDetails, [InvoiceDate] = Today()-1 ||  [InvoiceDate] = today() -2 ) )
 
but it doesn't give me the right count. So I tried this:
 
Shipped early = 
countrows(filter(DeliveryDetails, [InvoiceDate] < Today()-2)
,FirstConfirmed=today()-1)
 
I am usually an SQL person and would like to use a WHERE for the last line. I.e. when Transdate is yesterday, how many rows were invoiced (at any time before yesterday) for lines that were confirmed for yesterday.
 
I hope it makes a little bit of sense. If not, maybe someone could guide me towards a WHERE substitute? I tried this, but that didn't work either (maybe it's just a comma or something else really simple?)
:
Shipped early =
countrows(filter('DeliveryDetails'[InvoiceDate] = Today()-2 , 'DeliveryDetails'[FirstConfirmedDlvDate]<today()-1 ) )
  • Cadenze ,  Try like

    Shipped early =
    countrows(filter('DeliveryDetails', 'DeliveryDetails'[InvoiceDate] = Today()-1 && 'DeliveryDetails'[FirstConfirmedDlvDate]<today()-1 ) )

3 Replies

  • Cadenze ,  Try like

    Shipped early =
    countrows(filter('DeliveryDetails', 'DeliveryDetails'[InvoiceDate] = Today()-1 && 'DeliveryDetails'[FirstConfirmedDlvDate]<today()-1 ) )

    • Cadenze's avatar
      Cadenze
      Helper II

      This is the closest I have come to a working measure, so thank you for that. And once I put my head back on, I found that I needed to switch InvoiceDate and FirstConfirmedDlvDate in you excellent query :-).

  • amitchandak . Of course, when I check my data today, that field is empty because yesterday was Sunday and the day before that was Saturday. both of which have no activity. Is it possible to modify the sentence so it only uses workdays Mon-Fri?