cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TrentS Regular Visitor
Regular Visitor

Logic help IF? Switch? Contains?

Hope all are having a good day. My Search-FU is weak today and I need help.

I have a data model with two tables, a connection to a DB that is updated a few times per day. It also has a static Excel file for referencing customer names.

The Customer Name field from within the DB can have new entries added and is a simple text field. So, one entry might be ACME, the next ACME Inc. and the next Acme Co.

The spreadsheet aims to reduce the number of names displayed in the filter. In this case, we just want ACME to show and return all entries associated. The spreadsheet is manually updated periodically where column A is updated to match the Customer Name field from the DB and column B has the common name (ACME).

 

I am stuck on how to implement it. I am thinking that a new column in the DB model should be added with a measure that says If Customer Name is found in column A of the Excel table and there is data is column B, use B. Otherwise, use the original value from the DB. (In this case all of the varied Acme names have just Acme in column B.)

 

This should take care of the fact that new entries may not be found in the static file yet return the common name if it is.

 

I'm thinking it is a IF and Contains statement, I am just blanking on how to structure it.

 

Thanks for your time!

Trent

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Logic help IF? Switch? Contains?

I would implement this as a custom column in Power Query.

 

if [Common] = "" then [DB] else [Common]

You could do the same thing as a calculated column in DAX

 

IF(ISBLANK([Common]), [DB], [Common])

 

 


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

3 REPLIES 3
Super User
Super User

Re: Logic help IF? Switch? Contains?

I would implement this as a custom column in Power Query.

 

if [Common] = "" then [DB] else [Common]

You could do the same thing as a calculated column in DAX

 

IF(ISBLANK([Common]), [DB], [Common])

 

 


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

TrentS Regular Visitor
Regular Visitor

Re: Logic help IF? Switch? Contains?

Greg,

 

I appreciate the quick response. While your answer was not the actual solution, you provided the trigger! Knocked me out of my singular thinking with your suggestions. Providing both of the implementation options was the extra bit.

 

It was actually a LOOKUP function that I used after some other column work.

 

Most appreciated and have a great day!

Highlighted
Super User
Super User

Re: Logic help IF? Switch? Contains?

Awesome, I probably wasn't visualizing the problem properly in my head. Glad you were able to solve it though!


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 73 members 1,189 guests
Please welcome our newest community members: