cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
PXJ
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

BrandPC
Nissan123
Subaru456
Toyota789
Mazda987
Audi654
BMW658
Mercedes321
Nissan951
Subaru753
Toyota852
Mazda258

 

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

 

Thanks for your help.

2 ACCEPTED SOLUTIONS
tackytechtom
Super User
Super User

Hi @PXJ ,

 

Here a solution in Power Query:

tackytechtom_0-1683006275363.png

 

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 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/





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

Proud to be a Super User!




View solution in original post

tackytechtom
Super User
Super User

@PXJ ,

 

Here a solution as a calculated column in DAX:

tackytechtom_1-1683006632975.png

 

 

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 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/ 🙂

 

 





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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
tackytechtom
Super User
Super User

@PXJ ,

 

Here a solution as a calculated column in DAX:

tackytechtom_1-1683006632975.png

 

 

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 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/ 🙂

 

 





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

Proud to be a Super User!




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

tackytechtom
Super User
Super User

Hi @PXJ ,

 

Here a solution in Power Query:

tackytechtom_0-1683006275363.png

 

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 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/





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

Proud to be a Super User!




Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors