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
CloudHerder
Resolver I
Resolver I

Calculate using columns with duplicated data

I'm working with some messy sales win/loss data, and I need help. My goal is to calculate vendor consideration rate and vendor win rate. The data table includes the following columns:

  • ID: a unique ID for each deal
  • Winning Vendor: the name of the vendor who won the deal
  • Losing Vendors: the names of all other vendors considered, but not chosen (delimited with semicolons)

I've parsed the Losing Vendors field into separate rows in Power Query. The result for the 'Deals' table looks like this:

IDWinning VendorLosing Vendors
1Vendor AVendor B
1Vendor AVendor C
1Vendor AVendor D
2Vendor BVendor A
2Vendor BVendor D
3Vendor BVendor C
3Vendor BVendor E
4Vendor CVendor A
4Vendor CVendor B
4Vendor CVendor D
4Vendor CVendor E
4Vendor CVendor F
5Vendor D 
6Vendor AVendor B
6Vendor AVendor E
6Vendor AVendor F
7Vendor EVendor B
7Vendor EVendor C
7Vendor EVendor D
7Vendor EVendor F
8Vendor BVendor A
8Vendor BVendor C
8Vendor BVendor D
8Vendor BVendor E
8Vendor B

Vendor F

 

Calculating the respective vendor win rates is easy enough:

Vendor Win Rate =

DIVIDE(DISTINCTCOUNT([ID]),

CALCULATE(DISTINCTCOUNT([ID]), ALL(Deals[Winning Vendor])),0)

 

Summarizing the data for Losing Vendors is just a straight COUNT of ID for each vendor in the Losing Vendors column.

My challenge is in joining the two calculations, since the vendor names are duplicated across the two columns. Put another way, how do I join the two different vendor name fields so I can get counts for both wins and losses for each vendor?

 

I tried creating a UNION table of distinct vendor names, but when I create a relationship with 'Deals'[Losing Vendors] and try to make it active, I get an error:

You can't create a direct active relationship ... because an active set of indirect relationships already exists between these tables.

 

The calculation I want to be able to make include:

Vendor Consideration Rate = ([Win Count] + [Loss Count]) / [Deal Count]

 

I then want to create a scatter plot of vendors with Vendor Consideration Rate on the x-axis and Vendor Win Rate on the y-axis.

 

I have created an Excel file with the result I want here:

Vendor Win-Loss.xlsx

And a .pbix file with what I've tried so far here:

Vendor Win-Loss.pbix

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@CloudHerder Probably the easiest way is to create a disconnected table that lists all of your vendors. We will call this the Vendors table and the column that holds the names of the vendors is called Vendor. Then you can put this into a visualization along with this measure:

Measure = 
  VAR __Vendor = MAX('Vendors'[Vendor])
  VAR __Deals = COUNTROWS(DISTINCT('Deals'[ID]))
  VAR __Wins = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER('Deals',[Winning Vendor] = __Vendor),"__ID",[ID])))
  VAR __Losses = COUNTROWS(FILTER('Deals',[Losing Vendor] = __Vendor))
RETURN
  DIVIDE(__Wins + __Losses, __Deals, 0)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@CloudHerder Probably the easiest way is to create a disconnected table that lists all of your vendors. We will call this the Vendors table and the column that holds the names of the vendors is called Vendor. Then you can put this into a visualization along with this measure:

Measure = 
  VAR __Vendor = MAX('Vendors'[Vendor])
  VAR __Deals = COUNTROWS(DISTINCT('Deals'[ID]))
  VAR __Wins = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER('Deals',[Winning Vendor] = __Vendor),"__ID",[ID])))
  VAR __Losses = COUNTROWS(FILTER('Deals',[Losing Vendor] = __Vendor))
RETURN
  DIVIDE(__Wins + __Losses, __Deals, 0)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 
Thank you. That works!
I had previously created a table of all vendors using a UNION statement, as follows:

All Vendors =
VAR vendorTable = FILTERDISTINCTUNION(
        VALUES(Deals[Winning Vendor]),
        VALUES(Deals[Losing Vendors]))),
   NOT( ISBLANK([Winning Vendor])))
RETURN
SELECTCOLUMNS(vendorTable, "Vendor", [Winning Vendor])
My problem was that I had linked it back to the original 'Deals' table. When I disconnect it and use it in the measure you provided, it also works.

Thanks again!

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.

Top Solution Authors