Thursday, November 14, 2013

Power Pivot: unable to convert a value to the data type requested

I just ran into an (for me strange) issue when I was updating a Power Pivot workbook.
I had 2 columns in a table, let's say "One" and "Two", where One has integer values and Two string values. In my model I created a calculated column Three to concatenate these values. Because One and Two are actually redundant and never used on its own, I decided to delete those columns and save some space (the tables contained just over 2.2 million records).
So I started with updating my source view to concatenate the values in T-SQL, but when I refreshed the table in Power Pivot I got the error:
"Unable to convert a value to the data type requested in table x for column Three"

This error occured because I renamed the column in the view One and I already had that column present in my PP earlier (although I deleted it before opening the Table Properties). So my column One was previous INT, but would now be VARCHAR, however PP keeps this setting in mind although the column was deleted.

I found an answer on StackOverflow:
http://stackoverflow.com/questions/6981688/powerpivot-sql-query-fails-unable-to-convert-a-value-to-the-data-type-requeste

My solution was to recreate the column One in my PP and leave it empty (this would get the data type INT), and then add the new column One from the source in the Table Properties. This gives a warning that the column is already present in your workbook, but solves it by renaming the new column to "One 1" when refreshing the changes. After that you can delete the old column One and rename "One 1" to One and you're done!

So in short:

  1. Recreate the column (One) you deleted
  2. Then add the newly added column from your source with the same name
  3. PP renames the new column to "One 1"
  4. Delete the old column (One) again and rename "One 1" to One, or the desired name

Tuesday, November 5, 2013

SQL Rally Amsterdam 2013


Of course I would have loved to go to the PASS Summit this year, but unfortunately that wasn't going to happen according to my employer..
But then I heard that SQL Rally was coming to Amsterdam and saw my opportunity.
I read several posts from Allen, Brent and PASS itself on the topic How to Convince Your Boss... I had my hotel reservation ready, my arguments lined up (with even some backups to negotiate).. But he just said: "Well, that sounds like a good idea, just book it! :-)
The only catch was that I was asked to talk about a few of the topics on a study night to some of my co-workers. Well, that wouldn't be too hard I guess!

I hope to see a lot of my SQLFamily (Twitter-)friends in Amsterdam in the next 3 days! Do grab on to me and we'll have a chat!

Wednesday, October 30, 2013

Suggested reading

I came across some nice articles and blog posts in the last weeks I wanted to share:
SQLRally Nordic and Amsterdam will be held next week, I believe you can still register.
I will be attending SQLRally Amsterdam, so I hope to see some of you over there!

Hopefully you can get somehting useful out of here!

@NickyvV

Friday, September 27, 2013

LastIndexOf in T-SQL: Get Filename out of Path

Just a quick post for a quick solution:

I'm trying to get some information about documents stored in a SQL Server 2005 database. The documents are stored in an nText field in a table (called archive), but metadata is stored in other fields and tables.
I have the original filepath, but I wanted to get only the filename (+extenstion).

So actually, I was looking for some sort of T-SQL equivalent of the LastIndexOf C#-function. I couldn't find it easily so I thought substrings and CHARINDEX will do.. :)
Filepath is the column that contains the original filepath in the beneath code example:

RIGHT(filepath, CHARINDEX('\',REVERSE(filepath))-1)
LastIndexOf in T-SQL



When filepath = 'C:\temp\new\1\document.doc' this returns 'document.doc'
It basically:

  • reverses the column filepath
  • searches for the first '\'-character (so actually the last)
  • and returns the part to the right of the '\'.


@NickyvV

Friday, August 30, 2013

Suggested Reading

I came across some nice articles and blog posts in the last weeks I wanted to share:
Hopefully you can get somehting useful out of here!

@NickyvV

Thursday, August 15, 2013

Suggested Reading

I came across some nice articles and blog posts in the last weeks I wanted to share:
Hopefully you can get somehting useful out of here!

You can also follow me on Twitter: @NickyvV

Thursday, June 20, 2013

Suggested reading

I came across some nice articles and blog posts in the last weeks I wanted to share:

Hopefully you can get somehting useful out of the links!

You can also follow me on Twitter: @NickyvV

Featured Post

Power Apps or Translytical Task Flows?

I think I have gotten this question at least five or six times in the last few months, and with Translytical Task Flows reaching GA in the M...