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
LewisB
Frequent Visitor

Create a new column based on value existing in another

I am trying create a new column that confirms if a customer has bought product from both distributors. An example data set is below. Most companies only buy from one distributor, however there are some that buy from both. I want to be able to filter out the customers that buy from both distributors (eg. Have a new column called "Buy from both?")

 

The columns I'm using below are 'Customer'[Customer Name], 'Distributor'[Distributor Name] and 'Key Measures'[Revenue].

These columns also exist in my fact table (called 'Orders'). eg.  'Orders'[Customer Name], 'Orders'[Distributor Name] etc.

 

Distributors.PNG

 

I understand that this will most likely involve nested IF AND statements, but I am unable to get it to work!

 

Does anyone have tips to point me in the right direction?

3 REPLIES 3
mahoneypat
Employee
Employee

One way to do this (if you have only two distributors) would be with a measure like this

 

Both Distributors = IF(DISTINCTCOUNT('Orders'[Distributor Name])>=2, "Y", "N")

 

That should work in a table visual with the Customer Name column.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks Pat

 

I actually have 4 distributors, however only 2 actually share customers. What modification should I make to the measure?

Hi,

So you want to know how many customers (and which customers) buy from more than 1 distributor.  Am i correct?  Please share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.