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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
MoodyDirk
New Member

DAX CALCULATE COUNTROWS with Date filter not working ...

O.K., this is embarrasing, but this DAX measure ...

 

HeadCount =
CALCULATE(COUNTROWS('FACT_employees'),
'FACT_employees'[started] <= 12/15/2021
)
 
... does not return any results. FACT_employees[started] is a Data type Date, Format mm/dd/yyyy.
 
This works fine ...
HeadCount =
CALCULATE(COUNTROWS('FACT_employees'),
'FACT_employees'[status] = "Active"
)
 
... FACT_employees[status] is a Data type Text, Format Text.
 
Any feedback, ideas, on why does this does not work for a Date type column is highly appreciated.
 
Googling this for a day, tried all sorts of different ways to counts rows with a date filter, but none is working.
I'm working with PowerBI Desktop September 2022, Version 2.109.642.0 64-bit.
 
Doing this ...
 

select
*
from dbo.FACT_employees_view
where

(status = 'active' and started <= '2021-12-15')

 

... on MS SQL and it works fine, but here the started column is of text format, changed to Date in PowerBI Column Tools.

 

Dirk

 
 
1 ACCEPTED SOLUTION
AnthonyJoseph
Resolver III
Resolver III

Hi   @MoodyDirk

I think you should wrap the date coumn with the date function for comparision, so the measure would look like

 

HeadCount = CALCULATE(COUNTROWS('FACT_employees'), 'FACT_employees'[started] <= date(2021,12,15) )

 

This should work but let us know otherwise...

 

Thanks,

AnthonyJoseph

 

 

 

View solution in original post

2 REPLIES 2
AnthonyJoseph
Resolver III
Resolver III

Hi   @MoodyDirk

I think you should wrap the date coumn with the date function for comparision, so the measure would look like

 

HeadCount = CALCULATE(COUNTROWS('FACT_employees'), 'FACT_employees'[started] <= date(2021,12,15) )

 

This should work but let us know otherwise...

 

Thanks,

AnthonyJoseph

 

 

 

Yes, this works,

 

Thank You, Anthony.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.