Forum Discussion

airportplanner's avatar
airportplanner
Frequent Visitor
8 years ago
Solved

IF statement with LEN, LEFT & RIGHT formulas

Hello, new to Power Bi, sorry if this is a basic question.

 

I have a column with 2 types of data (lets call it Flight No Colunn) : BA254/BA879 and BA463/548

 

I have created a helper column that returns the length of each cell (11 or 9)

 

I would like to create an if command like this:

 

IF(LEN[Flight No Column]=11, RIGHT[Flight No Column, 5], CONCATENATE(LEFT([Flight No Column], 2), RIGHT([Flight No Column], 5))

 

However, this does not work as I am combining numbers with text in the same formula.

 

Do you have any suggestions?

 

Thank you very much

 

 

 

  • NipponSahore's avatar
    NipponSahore
    8 years ago

    i only changed the position of the parentheses

     

    Column 2 = IF(LEN(Table1[Flight No Column]) =11, RIGHT(Table1[Flight No Column], 5), CONCATENATE(LEFT(Table1[Flight No Column], 2), RIGHT(Table1[Flight No Column], 3))

10 Replies

  • Can you provide an example of the output you are looking for in both scenarios (LEN 9 and 11). I ran your code, adding the appropriate () and this is the result:

     

    • airportplanner's avatar
      airportplanner
      Frequent Visitor

      Thank you for your time. Trying to replicate your code i get this

       

      • NipponSahore's avatar
        NipponSahore
        Resolver II
        if (LEN(Table1[Column]) = 11, right(Table1[Column],5), CONCATENATE(left(Table1[Column],2),RIGHT(Table1[Column],3)))

        is the correct function