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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
CPaceFOTL
Frequent Visitor

Count Records Based off of Date Calculation

I have written a measure to determine the next upcoming Friday's date based off of today's date.  I'm sure there is a better way, but basically I used a combination of CALCULATE, IF and WEEKDAY to determine how many days needed to be added to TODAY to get the upcoming Friday, if not Friday already.

 

Now I am wanting to use this calculation in another measure to determine how many items are due by the upcoming Friday; however, I get the error that a calculation can not be used as  a filter.  Is there a way around this?

 

My data has a "Due By" date, so I want to count the number of rows that are not in a CLOSED or REJECTED status (another column in the rows) that are "due by" the upcoming Firday.

 

The masure I was trying is below.

 

Due_By_FRI = CALCULATE(COUNT([defect_id],[defect_status]<>"Closed",[defect_status]<>"Rejected",[ECT]<=[FRI_DTE]

 

I get the below error

 

A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

If I change [FRI_DAE] to TODAY(), then it will count the number today by TODAY or if I do TODAY()+/- n it will give me the number due by today +/- the number.  However, I want it to due this automatically.

 

Any suggestions would be greatly appreciated.

 

Thanks,

 

C Pace

1 ACCEPTED SOLUTION
BhaveshPatel
Community Champion
Community Champion

You should use FILTER function as a filter argument in the CALCULATE. Something like below...

 

Due_By_FRI = CALCULATE(COUNT([defect_id],[defect_status]<>"Closed",[defect_status]<>"Rejected",FILTER('defectstable,[ECT]<=[FRI_DTE]))

 

Is [ECT] a measure or column?

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

2 REPLIES 2
BhaveshPatel
Community Champion
Community Champion

You should use FILTER function as a filter argument in the CALCULATE. Something like below...

 

Due_By_FRI = CALCULATE(COUNT([defect_id],[defect_status]<>"Closed",[defect_status]<>"Rejected",FILTER('defectstable,[ECT]<=[FRI_DTE]))

 

Is [ECT] a measure or column?

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Thank you very much Bhavesh!  This worked great and gave me the results just like I wanted.  To answer your question, ECT is a column in the table data.

 

Thanks,

 

Craig

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.