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

DAX Create column based on conditions

Hi All,

 

PlatformDate1Date2
Apple12/01/2123/08/21
Sony12/11/2119/03/21
Apple09/10/2112/12/20
Microsoft09/08/2008/05/22

 

I am trying to create a simple custom column in Power BI but unfortuately I keep running into errors.

What I want to do is if the Platform is "Sony" or "Apple" populate Date1, otherwise populate Date2.

 

What I'm currently using is, but this isn't working

 

CustomerColumn = if 'Data'[Data.Platform]= "Sony" then 'Data'[Data.Date1] else if 'Data'[Data.Platform]= "Apple" then 'Data'[Data.Date1] else 'Data'[Data.Date2]

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@obriaincian , The above is Power Query. In DAX you can try like

 


CustomerColumn = Switch( True() ,
'Data'[Data.Platform]= "Sony" , 'Data'[Data.Date1] ,
'Data'[Data.Platform]= "Apple" , 'Data'[Data.Date1] ,
'Data'[Data.Date2])

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@obriaincian , The above is Power Query. In DAX you can try like

 


CustomerColumn = Switch( True() ,
'Data'[Data.Platform]= "Sony" , 'Data'[Data.Date1] ,
'Data'[Data.Platform]= "Apple" , 'Data'[Data.Date1] ,
'Data'[Data.Date2])

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.