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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

If with LookUpValue returning a value based on the entire table

Hi everyone,

 

I am looking to create a new column that returns "Won" or "Loss" based on three conditions. The issue with just making a new column like that is the the table I am working with has two files in it. A Quotes file and Sales. The quotes file has 47,000 records and the sales file has 840,000 records. 

 

I cannot compare the columns as they are not lined up by row and do not match.

 

NewPlsHelp_0-1625854447059.png

Above is an example of the data I have where there are many null values for the Quote side of the table, but the sales side is very full. The DesiredOutput column is what I want as an example.

 

If QuoteCustomer = SalesCustomer, QuoteProduct = SalesProduct, QuoteQuantity = SalesQuantity, "Won","Loss"

 

The if function above, syntax is not correct I know, is what I am trying to compare across the entire table.

 

I am thinking an LookUpValue function with an if condition would work as I need to base it off the entire table rather than row-by-row. 

 

Thank you!

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

The following Calculated column will get you what you need, where your data is in a single table

 

Desired Output = 
var _cust = 'sample'[SalesCustomer]
var _prod = 'sample'[SalesProduct]
var _qty = 'sample'[SalesQuantity]
return 
if(
    CALCULATE(COUNTROWS('sample'), FILTER(ALL('sample'), _cust = 'sample'[QuoteCustomer] && _prod = 'sample'[QuoteProduct] && _qty = 'sample'[QuoteQuantity]))>0,
     "Won",
      "Lost"
    )

 

richbenmintz_0-1625856800923.png

Hope that Helps



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


View solution in original post

8 REPLIES 8
richbenmintz
Solution Sage
Solution Sage

Hi @Anonymous ,

 

Are you able to share a sample pbix file with the two tables that need to be compared? or at least some sample data.

 

Thanks,



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Hi @Anonymous,

 

The following Calculated column will get you what you need, where your data is in a single table

 

Desired Output = 
var _cust = 'sample'[SalesCustomer]
var _prod = 'sample'[SalesProduct]
var _qty = 'sample'[SalesQuantity]
return 
if(
    CALCULATE(COUNTROWS('sample'), FILTER(ALL('sample'), _cust = 'sample'[QuoteCustomer] && _prod = 'sample'[QuoteProduct] && _qty = 'sample'[QuoteQuantity]))>0,
     "Won",
      "Lost"
    )

 

richbenmintz_0-1625856800923.png

Hope that Helps



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

You are an amazing human. I didn't know you could create a variable like that. Thank you thank you thank you!

@Anonymous ,

 

That is a bit execise :->, but thank you!



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

@richbenmintz 

It is now one table and the picture I included in the post is an example of some sample data I have. The last column is a the column I am looking to create 

Hi @Anonymous ,

 

Including the data as a table rather than an image makes it a whole lot easier to create a mockup, give me a couple minutes and I Can get a formula for you



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

Oh that makes a lot more sense. I'm sorry about that. I'm new to Power BI and the forums. I will keep that in mind in the future. 

You may want to take a look at the top post in the forum. It has some good tips on getting faster answers to your questions (because you're making it easier for people answer):

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/td-p/1447523/jump...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.