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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ANKITBISANI
Advocate I
Advocate I

Calculated columns with multiple IF's conditions

Hello All ,

 

I have a scenario as below . I need to have a calculated columns with below condition as shown in the below table(Calculated columns).

 

I have used switch as below but not getting the answer:

 

Column = SWITCH(CF_Savings_Ownership[Attribute],"One year ago", CF_Savings_Ownership[page2_WT] * 1 ,
"Two years ago", CF_Savings_Ownership[page2_WT] * 2,
"More than 5 years ago", CF_Savings_Ownership[page2_WT] * 5,"null")

 

 

Attributepage2_wt                                      calculated columns
More than 5 years ago0.023(if attribute = 'one year ago ' then page2_wt * 1 ,if attribute = 'Two years ago ' then page2_wt* 2 ,If attribute = 'More than 5 years ago' then page2_wt * 5)
More than 5 years ago1.023
More than 5 years ago2.023
One year ago3.023
One year ago4.023
More than 5 years ago5.023
More than 5 years ago6.023
More than 5 years ago7.023
Two years ago8.023

 

Regards ,

Ankit

1 ACCEPTED SOLUTION

Hi @ANKITBISANI,

 

You can also try to use switch function.

 

Calculate column:

 

Reuslt = 
var multi=SWITCH([Attribute],"one year ago",1,"Two years ago",2,"2-5 years ago",3.5,"More than 5 years ago",5,0)
return
[page2_wt]*multi +if(multi=0,2000)

 

Regards,

Xiaoxin sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
ANKITBISANI
Advocate I
Advocate I

Hello All

 

if [Attribute]= "One year ago" then 1 else if [Attribute]="Two years ago" then [page2_WT]*2 else if

[Attribute]="2-5 years ago" then [page2_WT]*3.5 else if [Attribute]="More than 5 years ago" then [page2_WT]*5 else 2000

 

Regards

 

Hi @ANKITBISANI,

 

You can also try to use switch function.

 

Calculate column:

 

Reuslt = 
var multi=SWITCH([Attribute],"one year ago",1,"Two years ago",2,"2-5 years ago",3.5,"More than 5 years ago",5,0)
return
[page2_wt]*multi +if(multi=0,2000)

 

Regards,

Xiaoxin sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.