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

using two filters one with text and one date

So I need a measure which shows a count of members who have raised a case in the current month, who have an eligibility flag of "yes"

So I can do a distinct count of member ID for the number of members, and then filter on case creation date looking at the current month and year, but when I try to add a filter for eligibility = "yes" my measure kicks off saying I cannot use a True/False expression that is used as a table filter expression.

 

Here is my incorrect attempt:

Eligible Members this Month = CALCULATE(DISTINCTCOUNT('Members'[MemberID]),MONTH('Case'[Createdon])=month(TODAY())&&YEAR('Case'[Createdon]=YEAR(TODAY())&&FILTER('Members','Members'[Eligible]="Yes")))

Is there anything I can do within the measure to resolve this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable


@Riantilo  you almost had it, without closing off the &&Year with three close brackets the measure believes the final filter is for the YEAR argument. 

So the below works! Thanks for your help! 🙂 

Eligible Members this Month =
CALCULATE(
DISTINCTCOUNT('Members'[MemberID]),
MONTH('Case'[Createdon])=month(TODAY()) &&
YEAR('Case'[Createdon]=YEAR(TODAY())) ,
FILTER(
'Members',
'Members'[Eligible]="Yes"
)
)

View solution in original post

3 REPLIES 3
Riantilo
Frequent Visitor

I think u can fix this bij changing the last && to a , 

This should work:
Eligible Members this Month =
CALCULATE(
DISTINCTCOUNT('Members'[MemberID]),
MONTH('Case'[Createdon])=month(TODAY()) &&
YEAR('Case'[Createdon]=YEAR(TODAY()) ,
FILTER(
'Members',
'Members'[Eligible]="Yes"
)
)

Anonymous
Not applicable


@Riantilo  you almost had it, without closing off the &&Year with three close brackets the measure believes the final filter is for the YEAR argument. 

So the below works! Thanks for your help! 🙂 

Eligible Members this Month =
CALCULATE(
DISTINCTCOUNT('Members'[MemberID]),
MONTH('Case'[Createdon])=month(TODAY()) &&
YEAR('Case'[Createdon]=YEAR(TODAY())) ,
FILTER(
'Members',
'Members'[Eligible]="Yes"
)
)

I copied the code from the original post. And dit not see that mistake. 

YEAR('Case'[Createdon]=YEAR(TODAY()))

 That explains why it didn't work.

 

to explain the error: The FILTER function can only be used in its own CALCULATE filter expression and can not be combined with the && or || operators.

 

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.