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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pooramit4
New Member

Alphanumeric column error

I am PBI beginer. I have a dataset in excel with Duration column as Alphanumeric. Below is the snapshot

pooramit4_0-1719998095031.png

When loading it to Power BI, getting error for YTD.

Is there any other way to write this YTD so that I do not get the error and the sheet is uploaded in proper manner.

1 ACCEPTED SOLUTION

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...

collinsg_1-1720511572892.png

gives...

collinsg_0-1720511552531.png

Hope this helps.

View solution in original post

6 REPLIES 6
foodd
Super User
Super User

Hello @pooramit4 . To encourage Community Members to assist you with your question, please provide your work-in-progress Power BI Desktop file (with sensitive information removed) that covers your issue or question completely in a usable format (not as a screenshot). You can upload the PBIX file to a cloud storage service such as OneDrive, Google Drive, Dropbox, or to a Github repository, and then share a file’s URL.

https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.

collinsg
Super User
Super User

Good day pooramit4,

As AlienSx suggests it would be preferable to prepare the data upstream. If you have to deal with the data in Power Query you can transform the Duration column as follows,

  1. Check each entry to see if it starts with YTD.
  2. Transform the entry if it starts with YTD.

Here is sample code.

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMjYwVdJRCijKTylNLsnMz1OK1aGeeGSIi4KBqa6R0eCUigUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Duration = _t, Area = _t]),
#"Transform YTD" = Table.TransformColumns(Source, {{"Duration", each if Text.StartsWith(_,"YTD") then "20" & Text.Range(_,7,2) & Text.Range(_,4,2) else _, type text}})
in
#"Transform YTD"

giving...

collinsg_0-1720006386683.png

Hope this helps.

 

Thanks @collinsg for your support. 

But this code is too complicated for me.

In the image that I shared, the duration column has both numeric and alphanumeric dates like - the normal month date in DDYYMM Format as 202305 & YTD format like YTD 05-22 i.e. YTD MM YY.

Now to proceed with PBI, I have to normalise this column separately, I suppose.

As soon as I upload the sheet in PBI, the rows with YTD shows error.

How do I normalise this YTD. Or if I take it in different column, then whats the procedure.

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...

collinsg_1-1720511572892.png

gives...

collinsg_0-1720511552531.png

Hope this helps.

AlienSx
Super User
Super User

@pooramit4 transform Duration column to text before loading.

Thanks @AlienSx for you support.

But its not working as the column has both dates in DDYYMM Format as 202305 & YTD format like YTD 05-22 i.e. YTD MM YY.

Is there any other way?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Kudoed Authors