cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
willz06jw
Helper II
Helper II

DAX formula question: DISTINCTCOUNT of ID if row's ID is not something else in another row

Hi,

 

I have something I haven't been able to work out in DAX:

 

Here is the data:

idarea
1Secure
2Secure
2Adol
3Secure
4Secure
4Adol
5Secure
6Secure
7Secure
8Secure
9

Secure

 

I need to distinctcount the ID column IF an ID doesn't also have an "Adol" row.

 

Is this possible?

 

Thank you,

Will

1 ACCEPTED SOLUTION
speedramps
Community Champion
Community Champion

Thanks willz06jw for a well described problen with an example table and not screen shot.

It makes it so easy for me to download the data and build a solution.

I wish everyone did this!

 

If you ever need more help then please quote @speedramps in your questions and I will receive a notification.

I am always keen to help people who take the trouble to decsribe their problens clealy with examples.

 

Try this and display the answer in a card ......

 

Distinct ID without Adol =
 
// create a list of ids with Adol
VAR ids_with_adol =
CALCULATETABLE(
    VALUES(yourtable[id]),
    yourtable[area] = "Adol")

RETURN
// get discount excluding the above list
CALCULATE(
    DISTINCTCOUNT(yourtable[id]),
   NOT    yourtable[id]    IN     ids_with_adol
)
 
If your are new to DAX then noee that the NOT operator comes at the begining of the expression.
Novices sometimes try writing NOT IN which wont work. 🤔
 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

View solution in original post

1 REPLY 1
speedramps
Community Champion
Community Champion

Thanks willz06jw for a well described problen with an example table and not screen shot.

It makes it so easy for me to download the data and build a solution.

I wish everyone did this!

 

If you ever need more help then please quote @speedramps in your questions and I will receive a notification.

I am always keen to help people who take the trouble to decsribe their problens clealy with examples.

 

Try this and display the answer in a card ......

 

Distinct ID without Adol =
 
// create a list of ids with Adol
VAR ids_with_adol =
CALCULATETABLE(
    VALUES(yourtable[id]),
    yourtable[area] = "Adol")

RETURN
// get discount excluding the above list
CALCULATE(
    DISTINCTCOUNT(yourtable[id]),
   NOT    yourtable[id]    IN     ids_with_adol
)
 
If your are new to DAX then noee that the NOT operator comes at the begining of the expression.
Novices sometimes try writing NOT IN which wont work. 🤔
 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors