cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
sgodfrey Frequent Visitor
Frequent Visitor

compare a date field to a defined date

Hi,

 

I'm trying to count the number of rows where a certain date/time field has been met according to a statically defined date in DAX as the visual filter will not work with the particular viz I require.  Both the date and the time of that particular day need to be met, and it doesn't appear to be evaluating the date/time properly, as when the date/time portion of the filter are removed, all else returns fine.  passwordChange has Data Type set to Date/Time.  For example, I have tried the following without success:

 

PWDGT06152018_Enabled = CALCULATE (
    DISTINCTCOUNT(Table[acctname]), FILTER ('Table', 'Table'[AcctType]="Value" && 'Table'[EnabledDisabled]="Enabled" && 'Table'[passwordChange].[Date] >= 6/15/2018 2:30 PM))

 

 

PWDGT06152018_Enabled = CALCULATE (
    DISTINCTCOUNT(Table[acctname]), FILTER ('Table', 'Table'[AcctType]="Value" && 'Table'[EnabledDisabled]="Enabled" && 'Table'[passwordChange].[Date] >= 20180615143000 ))

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sgodfrey Frequent Visitor
Frequent Visitor

Re: compare a date field to a defined date

Thanks, still double-checking the results and math, but its definitely evaluating both the date and the time now!  🙂

View solution in original post

3 REPLIES 3
Super User I
Super User I

Re: compare a date field to a defined date

Hello,

 

Usually, it is good to use DATE() and TIME() functions for comparison.

 

Can you try:

PWDGT06152018_Enabled =
CALCULATE (
    DISTINCTCOUNT ( Table[acctname] ),
    FILTER (
        'Table',
        'Table'[AcctType] = "Value"
            && 'Table'[EnabledDisabled] = "Enabled"
            && 'Table'[passwordChange].[Date]
                >= DATE ( 2018, 06, 15 ) + TIME ( 14, 30, 0 )
    )
)


Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!

Stay up to date on  linkedin-logo.png
Read my blogs on  powerbi.tips_.png



Community Support Team
Community Support Team

Re: compare a date field to a defined date

Hi @sgodfrey,

 

Have you solved your problem?

 

If you have solved, please accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

If you still need help, please share some data sample and your desired output so that we could help further on it.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sgodfrey Frequent Visitor
Frequent Visitor

Re: compare a date field to a defined date

Thanks, still double-checking the results and math, but its definitely evaluating both the date and the time now!  🙂

View solution in original post

Helpful resources

Announcements
Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors