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
AW1976NOVA
Post Patron
Post Patron

Is there a way to add a date filter to my created measure that has a summarize DAX statement?

Hi,

 

Here is an existing created measure that is working correctly.  However, I now need to add a date range type filter to it so I can modify it to capture data within a specific date range:

 

Here is the existing measure:

 

Member Months =
VAR Tab =
SUMMARIZE (
'Date Table',
'Date Table'[Month],
"Count Member ID",
DISTINCTCOUNT ( 'Eligibility Data'[Member ID (Elig)] )
)

RETURN
SUMX (
Tab,
[Count Member ID]
)
 
I now need to add a filter to this measure to capture the specific date range of:
( 'Date Table'[Date] >= 7/1/2019 && 'Date Table'[Date] <= 6/30/2020 ))
 
I know I want to create two additional Variables:
VAR Paid_DateStart = DATE ( 2019,7,1 )
VAR Paid_DateEnd = DATE ( 2020,6,30 )
 
I'm just not sure of where (or how) to include such a filter to my measure since I'm not overly familiar with the summarize function.  Can you please assist?
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@AW1976NOVA , try like

 

Member Months =
VAR Tab =
SUMMARIZE (
filter('Date Table', 'Date Table'[Date] >= date(2019 ,7,1) && 'Date Table'[Date] <= date(2020,6,30 ) )
'Date Table'[Month],
"Count Member ID",
DISTINCTCOUNT ( 'Eligibility Data'[Member ID (Elig)] )
)

RETURN
SUMX (
Tab,
[Count Member ID]
)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@AW1976NOVA , try like

 

Member Months =
VAR Tab =
SUMMARIZE (
filter('Date Table', 'Date Table'[Date] >= date(2019 ,7,1) && 'Date Table'[Date] <= date(2020,6,30 ) )
'Date Table'[Month],
"Count Member ID",
DISTINCTCOUNT ( 'Eligibility Data'[Member ID (Elig)] )
)

RETURN
SUMX (
Tab,
[Count Member ID]
)

I'm still getting an error with the syntax:  

 

Capture.PNG

 

Member Months 2 =
VAR Paid_StartDate =
DATE ( 2019, 7, 1 )
VAR Paid_EndDate =
DATE ( 2020, 6, 30 )
VAR Tab =
SUMMARIZE (
FILTER ('Date Table', 'Date Table'[Date] >= Paid_StartDate && 'Date Table'[Date] <= Paid_EndDate )
'Date Table',
'Date Table'[Month],
"Count Member ID",
DISTINCTCOUNT ('Eligibility Data'[Member ID (Elig)] )
)
RETURN
SUMX (
Tab,
[Count Member ID]
)
 
Is it possible that we have the filter section of the DAX incorrect?
 

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.