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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors