cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors