Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Direct Query: Remove characters from beginning Dax

I'm trying to remove the first 7 characters from a period list to leave the remaing 6 behind e.g. "Period 1 - 2018/19" to just 2018/19.

 

I'm working with direct query and have created a new column for this but it doesnt seem to work:

 

Sort Year =

RIGHT (

    LEFT (

        'looker_views lkr_Questionnaire'[Questionnaire_Title_Secondary],

        SEARCH ( "_", 'looker_views lkr_Questionnaire'[Questionnaire_Title_Secondary],1, LEN ( 'looker_views lkr_Questionnaire'[Questionnaire_Title_Secondary]) - 1 ) - 1

    ),

    LEN (

        LEFT (

            'looker_views lkr_Questionnaire'[Questionnaire_Title_Secondary],

            SEARCH ( "_", 'looker_views lkr_Questionnaire'[Questionnaire_Title_Secondary],1, LEN ( 'looker_views lkr_Questionnaire'[Questionnaire_Title_Secondary]) - 1 ) - 1

        )

    ) - 7

)

 

  • Ah, you've lost me there. I don't understand what you're telling me.

     

    This is the simplest I could come up with (not tested on Direct Query)

    ColumnText2 = IF (LEFT(TableX[theColumn],1) IN {"1", "2"} ,
       LEFT ( TableX[theColumn], 7)
    ,
       RIGHT ( TableX[theColumn], 7))

    May I also ask what the source system is because Power Query can do this if the source is SQL Server or a few others?

6 Replies