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
joyhackett
Helper II
Helper II

DAX query - should be simple, but I'm missing something

I have 2 tables that do not have a relationship:

Date (1/1/2019 - 12/31/2025)
- date_key
- full_date
EOM Month = FORMAT(DATE(1, MONTH('Date'[full_date]), 1), "mmmm")


Location (sample below)
- location_key
- start_date
- end_date

location sample data:
abc, 1/1/2020, 12/31/9999
lmn, 3/1/2022, 3/31/2022
xyz,  5/1/2022, 12/31/9999

My table should look like this:

EOMonthJan 2022Feb 2022Mar 2022Apr 2022May 2022
location count11212


And it does because my measure is this:

location count =
CALCULATE(
    DISTINCTCOUNTNOBLANK(Location[location_key]),
    Location[start_date] <= max('Date'[full_date]) && Location[end_date] >= max('Date'[full_date]))
   

But now, I want to filter based on the start_date and end_date, so if the user only wants to see locations that started between 3/1 and 5/1, abc will be filtered out and I'm left with:

EOMonthJan 2022Feb 2022Mar 2022Apr 2022May 2022
location count00101


I'm not sure how to add my start_date filter to the above DAX and still maintain the ability to show count by month.

All help appreciated! Thanks!

1 ACCEPTED SOLUTION
joyhackett
Helper II
Helper II

I guess I just needed to write it out 🙂

 

I'm not sure if this is the best way, but I found that if I add a hidden filter to my table where location_key is not null, then it works.

View solution in original post

1 REPLY 1
joyhackett
Helper II
Helper II

I guess I just needed to write it out 🙂

 

I'm not sure if this is the best way, but I found that if I add a hidden filter to my table where location_key is not null, then it works.

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.