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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

How to use DAX expression to find all distinct ids between certain dates

Hello, I just have a quick question.

 

So, we have a table called "Not_messaged' that has information about candidates. These fields are lastMessageDate (Date field), id (integer field), NotesMessageDate (Date field), and CallNotesLogDate (Date field).

 

what we want is to return a distinct count of ids that:

 

Do NOT have messagedLastSentDate before today's date
OR DOES NOT have callNotesLogdate = todays date
OR DOES NOT have NotesLogDate = today's date

 

I am trying to come up with a DAX expression that can return a distinct count of the ids. However, we are getting stuck because we're not good at DAX expressions.

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can put as many conditions as you want in a FILTER.

CALCULATE (
    DISTINCTCOUNT ( Not_messaged[id] ),
    FILTER (
        Not_messaged,
        Not_messaged[lastMessageDate] >= TODAY ()
            || Not_messaged[callNotesLogdate] <> TODAY ()
            || Not_messaged[NotesLogDate] <> TODAY ()
    )
)

 

View solution in original post

5 REPLIES 5
AlexisOlson
Super User
Super User

You can put as many conditions as you want in a FILTER.

CALCULATE (
    DISTINCTCOUNT ( Not_messaged[id] ),
    FILTER (
        Not_messaged,
        Not_messaged[lastMessageDate] >= TODAY ()
            || Not_messaged[callNotesLogdate] <> TODAY ()
            || Not_messaged[NotesLogDate] <> TODAY ()
    )
)

 

Syk
Super User
Super User

Seems like you just don't want today's date. You can add a date filter to the visual (or page/report)! Attached is an example of a date filter using the relative date filter type. 

Syk_0-1642100386070.png

 

smpa01
Super User
Super User

@Anonymous  please provide sample data and desired output.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Syk
Super User
Super User

I'd use the distinctcount function for DAX and then just use visual level filters to achieve what you're looking for

So something similar to

DISTINCTCOUNT('Not_messaged'[id])
Anonymous
Not applicable

I see, for the visual filters, can you do IF/OR statements?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

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.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.