Solved

My PowerPivot formula works on individual components but combination gives error

Posted on 2014-10-08
10
84 Views
Last Modified: 2014-10-08
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
Comment
Question by:Jorgen
  • 5
  • 5
10 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 40367792
Shouldn't your formula be:
=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

by:Jorgen
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

by:Jorgen
ID: 40367807
#ERR
0
 
LVL 85

Expert Comment

by:Rory Archibald
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

by:
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Author Comment

by:Jorgen
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

by:Rory Archibald
ID: 40367820
See my last post. :)
0
 
LVL 4

Author Comment

by:Jorgen
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

by:Jorgen
ID: 40367828
Great solution - and worth to remember in the future
0
 
LVL 85

Expert Comment

by:Rory Archibald
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now