Forum Discussion

pooramit4's avatar
pooramit4
New Member
2 years ago
Solved

Alphanumeric column error

I am PBI beginer. I have a dataset in excel with Duration column as Alphanumeric. Below is the snapshot When loading it to Power BI, getting error for YTD. Is there any other way to write thi...
  • collinsg's avatar
    collinsg
    2 years ago

    Good morning pooramit4 ,

    To cater for your data being numeric and alphanumeric I've added an initial conversion to text - Text.From(_), I finish by converting text values back to numeric - Value.FromText(...). If you add the following step to your Power Query query your data it will produce an output of numeric dates. Replace #"Previous Step" with the name of your previous step.

    = Table.TransformColumns(
    #"Previous Step",
    {{"Duration",
    each if Text.StartsWith(Text.From(_),"YTD")
    then Value.FromText("20" & Text.Range(_,7,2) & Text.Range(_,4,2))
    else _, type text
    }})

     This...

    gives...

    Hope this helps.