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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Create a Measure: Add an additional OR criteria

Hi,
 
I created a measure that I now need to add additional criteria to.  It is perfoming correctly but I'd now like to also include these instances:  'Claim Data Pull'[Service Code] IN {"76700", "76705", "76770", "76775", "G0389"}
 
The current formula is counting distinct Member IDs where:
- Gender = Male
- Age = 65 to 75
- Dx 1 = Z87.891, F17.210, F17.211, F17.213, F17.218, F17.219, Z00.00, Z00.01 or Z00.8
 
However, I now need it to also count/include instances where:
- Gender = Male
- Age = 65 to 75
- Service Code = 76700, 76705, 76770, 76775 or G0389
 
Current Formula:
Abdominal Aortic Aneurysm Participating = (CALCULATE(DISTINCTCOUNT('Claim Data Pull'[Member ID]), FILTER('Claim Data Pull','Claim Data Pull'[Gender]="Male"),'Claim Data Pull'[Age]>=65,'Claim Data Pull'[Age]<=75,'claim data pull'[Dx 1] IN {"Z87.891", "F17.210", "F17.211", "F17.213", "F17.218", "F17.219", "Z00.00", "Z00.01", "Z00.8"}))
 
So, how do I add OR functionality stating to count the original instances, but also these instances:
'Claim Data Pull'[Service Code] IN {"76700", "76705", "76770", "76775", "G0389"}
 
It is not as easy as this:
Abdominal Aortic Aneurysm Participating = (CALCULATE(DISTINCTCOUNT('Claim Data Pull'[Member ID]), FILTER('Claim Data Pull','Claim Data Pull'[Gender]="Male"),'Claim Data Pull'[Age]>=65,'Claim Data Pull'[Age]<=75,'claim data pull'[Dx 1] IN {"Z87.891", "F17.210", "F17.211", "F17.213", "F17.218", "F17.219", "Z00.00", "Z00.01", "Z00.8"})) (CALCULATE(DISTINCTCOUNT('Claim Data Pull'[Member ID]), FILTER('Claim Data Pull','Claim Data Pull'[Gender]="Male"),'Claim Data Pull'[Age]>=65,'Claim Data Pull'[Age]<=75,'Claim Data Pull'[Service Code] IN {"76700", "76705", "76770", "76775", "G0389"}))
 
...because there are some results with a Dx 1 match and Service Code match.  That would double count that instance.
 
 
Thank you!

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

@Anonymous 

try

Abdominal Aortic Aneurysm Participating = (
CALCULATE(DISTINCTCOUNT('Claim Data Pull'[Member ID]),
FILTER('Claim Data Pull','Claim Data Pull'[Gender]="Male" && 
'Claim Data Pull'[Age]>=65 &&
'Claim Data Pull'[Age]<=75 &&
(
'claim data pull'[Dx 1] IN {"Z87.891", "F17.210", "F17.211", "F17.213", "F17.218", "F17.219", "Z00.00", "Z00.01", "Z00.8"} ||
'Claim Data Pull'[Service Code] IN {"76700", "76705", "76770", "76775", "G0389"}
)
)

))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

Inside filter use || or and &&

Example

CALCULATE(DISTINCTCOUNT('Claim Data Pull'[Member ID]), FILTER('Claim Data Pull','Claim Data Pull'[Gender]="Male" &&'Claim Data Pull'[Age]>=65,'Claim Data Pull'[Age]<=75 && 'claim data pull'[Dx 1] IN {"Z87.891", "F17.210", "F17.211", "F17.213", "F17.218", "F17.219", "Z00.00", "Z00.01", "Z00.8"} || 'Claim Data Pull'[Service Code] IN {"76700", "76705", "76770", "76775", "G0389"}))

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I think Amitchandak's solution is pretty close but it also has an error:

 

"Too many arguments were passed to the FILTER function. The maximum argument count for the function is 2."

 

It looks like the || function is limited to only 2 arguments.  Since we already have an Age clause and a Dx 1 clause ... I don't this is correctly processing the Service Code clause.

az38
Community Champion
Community Champion

@Anonymous 

maybe

Abdominal Aortic Aneurysm Participating = (
CALCULATE(DISTINCTCOUNT('Claim Data Pull'[Member ID]),
FILTER('Claim Data Pull','Claim Data Pull'[Gender]="Male"),
'Claim Data Pull'[Age]>=65,
'Claim Data Pull'[Age]<=75,

OR(
'claim data pull'[Dx 1] IN {"Z87.891", "F17.210", "F17.211", "F17.213", "F17.218", "F17.219", "Z00.00", "Z00.01", "Z00.8"},
'Claim Data Pull'[Service Code] IN {"76700", "76705", "76770", "76775", "G0389"}
)

))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

I tried changing my formula to yours and I got the following error:

 

"The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression."

 

I don't this "OR" is a recognized function in DAX unfortunately.

 

 

az38
Community Champion
Community Champion

@Anonymous 

try

Abdominal Aortic Aneurysm Participating = (
CALCULATE(DISTINCTCOUNT('Claim Data Pull'[Member ID]),
FILTER('Claim Data Pull','Claim Data Pull'[Gender]="Male" && 
'Claim Data Pull'[Age]>=65 &&
'Claim Data Pull'[Age]<=75 &&
(
'claim data pull'[Dx 1] IN {"Z87.891", "F17.210", "F17.211", "F17.213", "F17.218", "F17.219", "Z00.00", "Z00.01", "Z00.8"} ||
'Claim Data Pull'[Service Code] IN {"76700", "76705", "76770", "76775", "G0389"}
)
)

))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.