cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## IFs excel

Hi all,

I am trying to achieve the below that I've created in excel in power bi:

Brand1=IF(Products[Brand]="Nissan", Products[Brand]&" "&"("&Products[PC]&")",Products[Brand]

IF(Products[Brand]="Subaru", Products[Brand]&" "&"("&Products[PC]&")",Products[Brand]

IF(Products[Brand]="Toyota", Products[Brand]&" "&"("&Products[PC]&")",Products[Brand]

IF(Products[Brand]="Mazda", Products[Brand]&" "&"("&Products[PC]&")",Products[Brand]

Products

 Brand PC Nissan 123 Subaru 456 Toyota 789 Mazda 987 Audi 654 BMW 658 Mercedes 321 Nissan 951 Subaru 753 Toyota 852 Mazda 258

 Brand1 Nissan (123) Subaru (456) Toyota (789) Mazda (987) Audi BMW Mercedes Nissan (951) Subaru (753) Toyota (852) Mazda (258)

2 ACCEPTED SOLUTIONS
Super User

Hi @PXJ ,

Here a solution in Power Query:

and here the code:

`if [Brand]="Nissan" then [Brand] & " (" & [PC] & ")" else if [Brand]="Subaru" then [Brand] & " (" & [PC] & ")" else if [Brand]="Toyota" then [Brand] & " (" & [PC] & ")" else if [Brand]="Mazda"  then [Brand] & " (" & [PC] & ")" else [Brand]`

Let me know if this works 🙂

 Also happily accepting Kudos 🙂

 Feel free to connect with me on LinkedIn!

 #proudtobeasuperuser

Super User

@PXJ ,

Here a solution as a calculated column in DAX:

And here the code:

```BrandCalculatedColumn =
SWITCH (
TRUE,
[Brand]="Nissan", [Brand] & " (" & [PC] & ")",
[Brand]="Subaru", [Brand] & " (" & [PC] & ")",
[Brand]="Toyota", [Brand] & " (" & [PC] & ")",
[Brand]="Mazda", [Brand] & " (" & [PC] & ")",
[Brand]
)```

Hope either of the solution helps 🙂

 Also happily accepting Kudos 🙂

 Feel free to connect with me on LinkedIn!

 #proudtobeasuperuser

3 REPLIES 3
Super User

@PXJ ,

Here a solution as a calculated column in DAX:

And here the code:

```BrandCalculatedColumn =
SWITCH (
TRUE,
[Brand]="Nissan", [Brand] & " (" & [PC] & ")",
[Brand]="Subaru", [Brand] & " (" & [PC] & ")",
[Brand]="Toyota", [Brand] & " (" & [PC] & ")",
[Brand]="Mazda", [Brand] & " (" & [PC] & ")",
[Brand]
)```

Hope either of the solution helps 🙂

 Also happily accepting Kudos 🙂

 Feel free to connect with me on LinkedIn!

 #proudtobeasuperuser

Frequent Visitor

Thanks very much Tom, it worked brilliantly.  Really appreciate your response, I was struggling with it.

Super User

Hi @PXJ ,

Here a solution in Power Query:

and here the code:

`if [Brand]="Nissan" then [Brand] & " (" & [PC] & ")" else if [Brand]="Subaru" then [Brand] & " (" & [PC] & ")" else if [Brand]="Toyota" then [Brand] & " (" & [PC] & ")" else if [Brand]="Mazda"  then [Brand] & " (" & [PC] & ")" else [Brand]`

Let me know if this works 🙂

 Also happily accepting Kudos 🙂

 Feel free to connect with me on LinkedIn!

 #proudtobeasuperuser

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors