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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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
Super User
Super User

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
Super User
Super User

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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