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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Cadenze
Helper II
Helper II

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Cadenze
Helper II
Helper II

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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