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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Cadenze
Frequent Visitor

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 ) )
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Cadenze ,  Try like

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

View solution in original post

3 REPLIES 3
Cadenze
Frequent Visitor

@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?

amitchandak
Super User
Super User

@Cadenze ,  Try like

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

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 :-).

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.