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
Jon8930
Regular Visitor

Adding a number to column from an IF statement

Hi,

 

I am trying to create a custom column using an if statement to report the following:

 

 

 

= each if [Asset Type] = "PC Tower" then [Year of Purchase] + 5 else 0

 

 

 

I want it to add 5 years to the "Year of purchase" based on its asset type.

 

This returns an error and need some help where I am going wrong.

 

Many Thanks

Jon

1 ACCEPTED SOLUTION
serpiva64
Super User
Super User

Hi,

each is wrong.

 

I have tried the following

if [FromCurrency]= "GBP" then [Year]+5 else [Year]

serpiva64_1-1676375080265.png

 

and it function.

in the formula bar it appears this way

= Table.AddColumn(#"Added Custom1", "Custom", each if [FromCurrency]= "GBP" then [Year]+5 else [Year])

pay attention to the type of your Year column

 

If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!

View solution in original post

2 REPLIES 2
serpiva64
Super User
Super User

Hi,

each is wrong.

 

I have tried the following

if [FromCurrency]= "GBP" then [Year]+5 else [Year]

serpiva64_1-1676375080265.png

 

and it function.

in the formula bar it appears this way

= Table.AddColumn(#"Added Custom1", "Custom", each if [FromCurrency]= "GBP" then [Year]+5 else [Year])

pay attention to the type of your Year column

 

If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!

Sorted it, Many thanks for your help.

 

Jon

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors
Top Kudoed Authors