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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
batmanadk
Helper I
Helper I

Column merging based on datatype

Hello guys! 
I'm stucked in one report and would really appreciate the help since I'm running out of time to turn this in.

So, this is for a restaurant that registers its clients in its POS system. 

Name: 
NIT:

Because of some operational issues, they had to swipe this, and now, the registration is 
NIT: 
Name: 

The problem is, the program doesn't register this info in columns, but it uses an entity to register all in one column as it follows:

Ticket Entity

{Customer name: A, Customer Nit: 111}

The problem is, that with the changed order, at some row point, data is different, like it follows

DateTicket Entity
01-01-2019{Customer name: A, Customer Nit: 111}
01-01-2020{Customer name: 112, Customer Nit: 112}

 

So, it is entering the NIT info in the customer name field... What I get after some transformations is this:

Customer NameCustomer Nit
A111
112B

 whereas it should be

Customer Name  Customer Nit
A111
B112

 

I've tried to do something in Power Query, such as:

Table.AddColumn(Table.AddColumn(yourtab, "num", each if Value.Is([yourMixedCol], type number) then [yourMixedCol] else null), "txt", each if Value.Is([yourMixedCol], type text) then [yourMixedCol] else null)

 

I've also tried duplicating both columns and after that, applying 2 custom columns, like it follows:

= let parsed = try Number.From([Origional Text]) in [Number = parsed[Value]?, Text = if parsed[HasError] then [Origional Text] else null]

where [Original text] is [Customer Name] in the first duplicate, and [Customer Nit] in the second one. After that, I have to delete the duplicated columns and merge the original columns with the custom columns. It works, but I'm not sure if by taking so many steps in the query editor it'll affect performance... Do you think I could apply a better solution? 

. What do you guys think? Really appreciate the help

2 REPLIES 2
pranit828
Community Champion
Community Champion

Hi @batmanadk 

 

It sucks to see the requirement change but we are developers and we do what we have to do to get the required output and adhere to the timeline.

 

In this case I would create two new columns s below and use it all the charts and graphs.

Customer_name = IF(ISNUMBER([Customer Name]),[Ticket Entity],[Customer Name])  //Change the data type to text

Ticket_Entity    =  IF(ISNUMBER([Ticket Entity]),[Ticket Entity],[Customer Name])  //change the datatype to whole number

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Thanks @pranit828  , yeah sorry about the edit, the thing is I got to a solution in the power query but it doesn't feel simple enough

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.