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
Anonymous
Not applicable

Dax filter syntax

Hello all

 

In DAX , how can i create a Measure that filter all values by a specific date for each value 

for example :

 I have a table with 3 columns : customer_id (PK) , country , register_date ( all data for all countries is from 1/1/2018 ) 

how can i create a parameter that filters the customer_id  by a diffrent and specific date for each a country  ?

show only customer_id from Spain that the  register_date is >= 2/14/2018

And

show only customer_id from Canada that the  register_date is >= 9/24/2018

And

show only customer_id from France that the  register_date is >= 7/30/2019

1 ACCEPTED SOLUTION
vivran22
Community Champion
Community Champion

Hello @Anonymous,

 

You may try this measure:

 

Customer Count =
VAR _Spain =
    DATE ( 2018, 2, 14 )
VAR _Canada =
    DATE ( 2018, 9, 24 )
VAR _France =
    DATE ( 2019, 7, 30 )
RETURN
    CALCULATE (
        COUNT ( dtTable[CustomerID] ),
        FILTER (
            dtTable,
            dtTable[Country] = "Spain"
                && dtTable[RegisterDate] >= _Spain
        )
    )
        + CALCULATE (
            COUNT ( dtTable[CustomerID] ),
            FILTER (
                dtTable,
                dtTable[Country] = "Canada"
                    && dtTable[RegisterDate] >= _Canada
            )
        )
        + CALCULATE (
            COUNT ( dtTable[CustomerID] ),
            FILTER (
                dtTable,
                dtTable[Country] = "France"
                    && dtTable[RegisterDate] >= _France
            )
        )

 

Then in the visual, you can add this as Filter = is not blank:

Capture.PNG

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

View solution in original post

2 REPLIES 2
vivran22
Community Champion
Community Champion

Hello @Anonymous,

 

You may try this measure:

 

Customer Count =
VAR _Spain =
    DATE ( 2018, 2, 14 )
VAR _Canada =
    DATE ( 2018, 9, 24 )
VAR _France =
    DATE ( 2019, 7, 30 )
RETURN
    CALCULATE (
        COUNT ( dtTable[CustomerID] ),
        FILTER (
            dtTable,
            dtTable[Country] = "Spain"
                && dtTable[RegisterDate] >= _Spain
        )
    )
        + CALCULATE (
            COUNT ( dtTable[CustomerID] ),
            FILTER (
                dtTable,
                dtTable[Country] = "Canada"
                    && dtTable[RegisterDate] >= _Canada
            )
        )
        + CALCULATE (
            COUNT ( dtTable[CustomerID] ),
            FILTER (
                dtTable,
                dtTable[Country] = "France"
                    && dtTable[RegisterDate] >= _France
            )
        )

 

Then in the visual, you can add this as Filter = is not blank:

Capture.PNG

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

Anonymous
Not applicable

Thank you very much @vivran22  ! it helped a lot !

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.