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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
krlowe
New Member

New DAX measure filtering by distinct count and two numeric variables

Hi folks,

I'm trying to create a percentile calculation in the end, but here are some details.

Table name=DTaP

Need to create new metric called "Vaccine at 2 Months" with the following filtering:

-distinctcount of ID variable

-Filter AgeMonths variable is less than or equal to 2

-Filter OrdinalPosition variable equals 1

 

Overall, I need to only take into consideration distinct IDs and filter across two numeric variables. I can't quite determine how to calculate and filter across all of these variables in DAX. Your help is much appreciated!

 

Thanks for the help!!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for rsbin and Kedar_Pande's concern about this issue.

  

Hi, @krlowe 

I am glad to help you.

 

Based on your description and the suggestions of others, I have created a simple pbix file that I hope will help you.

 

First, since you didn't give any test data, I created some of my own for testing:

vfenlingmsft_0-1735090714078.png

 


Then create a Measure Vaccine at 2 Months:

Vaccine at 2 Months = 
CALCULATE(
    DISTINCTCOUNT(DTaP[ID]),
    DTaP[AgeMonths] <= 2,
    DTaP[OrdinalPosition] = 1
)


Output:

vfenlingmsft_1-1735090803003.png

 

I have attached this pbix file below, hope it helps you.

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Thanks for rsbin and Kedar_Pande's concern about this issue.

  

Hi, @krlowe 

I am glad to help you.

 

Based on your description and the suggestions of others, I have created a simple pbix file that I hope will help you.

 

First, since you didn't give any test data, I created some of my own for testing:

vfenlingmsft_0-1735090714078.png

 


Then create a Measure Vaccine at 2 Months:

Vaccine at 2 Months = 
CALCULATE(
    DISTINCTCOUNT(DTaP[ID]),
    DTaP[AgeMonths] <= 2,
    DTaP[OrdinalPosition] = 1
)


Output:

vfenlingmsft_1-1735090803003.png

 

I have attached this pbix file below, hope it helps you.

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Kedar_Pande
Super User
Super User

@krlowe 

Measure:

Vaccine at 2 Months = 
CALCULATE(
DISTINCTCOUNT(DTaP[ID]),
DTaP[AgeMonths] <= 2,
DTaP[OrdinalPosition] = 1
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

elitesmitpatel
Solution Supplier
Solution Supplier

If @rsbin answer is not correct then please provide the dummy pbix file for easy reference and faster solution.

rsbin
Super User
Super User

@krlowe ,
Please try somthing like this (I am assuming you are referring to "variables" as your column fields 😞

Vaccine_at2Months = CALCULATE( DISTINCTCOUNT( DTaP[ID] ),
                    FILTER( DTaP, DTaP[AgeMonths] <= 2 &&
                                  DTaP[OrdnalPosition] = 1 ))

If this does not provide the solution you are looking for, please paste a sample of your data (as a table, not as a picture).

Hope this gets you started.

Regards and Happy Holidays,

 

Thanks all - I appreciate the help!!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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