Solved

# My PowerPivot formula works on individual components but combination gives error

Posted on 2014-10-08
85 Views
I try to create a formula in Power Pivot, where I try to generate a new column (or even better a measure if anybody can help on that

=mid([Placement],11,1) returns correctly the 11th character, if the [Placement] column has characters
=if(len([Placement])>0,1,2) returns correctly either 1 or 2 dependent on the length of [Placement]

But combining the two into one new Column like below generates an error

=if(len([Placement])>0,mid([Placement],11,1),2)

Urgent help is needed.

best regards

Jørgen
0
Question by:Jorgen
• 5
• 5

LVL 85

Expert Comment

ID: 40367792
=if(len([Placement])>10,mid([Placement],11,1),2)

I don't see how that could be a measure - it doesn't really make sense to me.
0

LVL 4

Author Comment

ID: 40367800
Hi Rory,

Most of the Placement records are actually blank, which is the reason for selecting 0. and I tried the measure part as well, and it did not make sense for me either. But I thought it was my lack of knowledge on the measures.

I will check if inserting 10 makes a difference, but I imagine it does not. Do you find any errors in the formula apart from the 10 figure?

best regards

Jørgen
0

LVL 4

Author Comment

ID: 40367807
#ERR
0

LVL 85

Expert Comment

ID: 40367809
If you have any records that are less than 11 characters, you'd get an error, which is why I suggested changing to > 10.
0

LVL 85

Accepted Solution

Rory Archibald earned 500 total points
ID: 40367814
Oh wait - will the 11th character always be a number? If so, use:
=if(len([Placement])>10,mid([Placement],11,1)+0,2)
If not, use:
=if(len([Placement])>10,mid([Placement],11,1),"2")

You can't have different data types returned by the two result arguments.
0

LVL 4

Author Comment

ID: 40367816
But I did not get the error on testing
=if(len([Placement])>0,1,2)
and I do also get an error using 10 - no difference at all :-(
0

LVL 85

Expert Comment

ID: 40367820
See my last post. :)
0

LVL 4

Author Comment

ID: 40367823
Hi Rory
Worked like a charm, when I inserted the +0.

Do you by any chance have any experience on the average ytd functionality in Power Pivot (in that case I will post another question)?

best regards

Jørgen
0

LVL 4

Author Closing Comment

ID: 40367828
Great solution - and worth to remember in the future
0

LVL 85

Expert Comment

ID: 40367892
I can't say I've ever used it but feel free to post it and I'm sure we can figure it out. :)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.