How to extract the number from a string in power pivot? - powerpivot

Hi i have a power pivot sheet with description column
which Values like this
PMS 1,500 Promo
Demo 25,000 Project
how can i get the number from the string?
my expected result is
Description value
PMS 1,500 Promo 1,500
Demo 25,000 Project 25,000
im new with power pivot :(

It's actually the same method you would use in an Excel formula.
I did this in a formula on a sheet, but you could do the same in a Calculated Column in PowerPivot
=VALUE(MID(A2,FIND(" ",A2)+1,FIND(" ",A2,FIND(" ",A2)+1)-FIND(" ",A2)))
It's a bit messy but does the job.

Related

Excel Query (QODBC / QuickBooks) Question: Is it possible to query an sp_report (in excel) and have 2 sets of amount columns?

For example, I am querying the trial balance sp_report and would like to have debit/credit columns for the current year and another set of debit/credit columns for the prior year.
Current code is:
sp_report TrialBalance show AccountType, Label, AccountFullName,
AccountName, Debit, Credit parameters DateMacro = 'ThisYear'
I would suggest creating three sheets in an Excel workbook. Sheet 1 for this year and Sheet 2 for the previous year. You can then use Sheet 3 and create a report by combining values from sheets 1 and 2.
Please feel free to contact us should you have any further queries on this issue related to QODBC.
For our first level free support option, you can create a ticket at http://support.qodbc.com/
For our second level (Remote/Phone/Email) Paid support option, you can create a ticket at http://www.qodbc.com/phsupport.htm

MSAccess Slow Updates on Self-Joined table

I am trying to improve the performance of updating only about 60K rows with data coming from different rows in the same table. At about 2 minutes, it's not terrible, but it's not great either, and my application really doesn't work if you have to wait so long between recalculations.
The app generates a set of financial statements for a business, where it calculates basic formulas on 1300 line items, like Rent, or Direct Labor, or Inventory costs, all of which roll up to totals that mimic the Balance Sheet, P&Ls, Cash Flow etc. Many of the line items need to calculate on a month by month basis, where for instance it has figure out April's On Hand Inventory before knowing what April's Inventory Value is. So the total program ends up looping through 48 months over 30 calculation passes, requiring about 8000 SQL statements. (fortunately it figures it all out by itself!) Each SQL is taking only a few milliseconds, but it adds up.
I'm pretty sure I can't reduce the number of loops, so I keep trying to figure out how to make each SQL quicker. The basic structure is as follows:
LI: Line item table that holds the basic info of each item, primary key LID
LID Name
123 Sales_1
124 Sales_2
200 Total Sales
Formula: Master/Detail tables that create any formula from the line items
Total sales=Sales_1 + Sales_2
or
{200}={123}+{124}
(I use curly braces to be able to find and replace the LIDs within the formula, as shown in the SQL below)
FC: Formula Calculation table: all line items by month, about 1300 items x 48 months=62K records. Primary key FID
FID SQL_ID LID LID_brace LIN OutputMonth Formula Amount
3232 25 123 {123} Sales_1 1 1200
3255 26 124 {124} Sales_2 1 1500
5454 177 200 {200} Total Sales 1 {123}+{124}
DMO:Operand Join table, which links a formula to its detail lines within the same table, so once Sales_1 is calculated, it can find the Total Sales record and update it, which then will evaluate then send its amount up the chain to the other LIDs that depend on it, such as Total Income. It locates the record to update based on the SQL_id, which is set based on the calc pass and month. Its complex to setup, but pretty straightforward once you actually run things
Master_FID Detail_FID
5454 3232 (links total sales to sales_1)
5454 3255 (links total sales to sales_2)
SQL1:
Update FC inner join DMO on FC.FID=DMO.Master_FID inner join FC2 on DMO.Detail_FID=FC2.FID set FC.formula=replace(FC.Formula,FC.LID_brace,FC2.Amount) where FC.sql_id=177
The above will change {123} + {124} to 1200+1500 which will then evaluate to 2700 when I run the following
SQL2:
UPDATE FC SET FC.amount = Eval([fc].[formula]) WHERE (((FC.calc_sql_id)=177 )
So those two sql statements are run over and over again, with the only thing changing is the SQL_id.
There are indexes on the SQL_ID, LID, FID etc
When measuring, the milliseconds per record can range from .04ms if there are many records included (~10K for some passes), up to 10 or 15 ms for just one record updated. Perhaps it is the setup of the query causing a whole lot of overhead time, because it doesn't seem to be a function of the actual number of records updated? Also its not very consistent, where some runs have 20+ ms compared to less than 3ms when it runs it again.
I know this is a complex question i'm asking that probably doesn't have a simple answer, but I'm just looking for directions for what might help. For instance, a parameter query if there isn't a whole lot of change between runs? Does Access have a better time of running a query if knows about it in advance, i.e a named query with parameters vs dynamic SQL? Am I just doomed because it still needs to run those 8000 queries?
Also, is there inherently a problem with trying to update the same table through a secondary join table, and/or is there a better way to do it?
Is it also because string replacing isn't efficient this way? If I tried RegEx would that be quicker? I would have to make a function that could do that within a query, but it seems like that's going to be slower.
Thanks in advance, this has been a most vexing problem!!!

Extracting data from SAS data set based on values with different length

I am looking to automate a process which has a sales dataset and a specific column named SALES CODE which is of 5 letters.
Based on the input given by the user I would like to filter the data but the problem is the user can give multiple sales codes and sometimes the length of codes could be 5,4,3,2 or 1 based on the condition. How will I filter out the required rows based on the above condition?
SALESCODE area value units rep
A10AA KR 100 10 Jay
B10AQ TN 120 12 Jrn
C10AH KR 200 10 Jay
T11TA TR 180 10 Jay
Say if I give the input as A10AA, B10A, T11 I should be able to
Get the sales data with codes A10AA, B10AQ, T11TA. kindly help.
Use the IN operator. Since you want to match values that start with the specified value use the : modifier. Since your values are character values make sure to include quotes.
proc print data=sales_data ;
where salescode in: ("A10AA" "B10A" "T11");
run;
If you want you can use commas between the values in the list, but I find it easier to type spaces instead.

PowerPivot Pivot Table displays all rows instead of context rows

I'm looking for guidance on what changes need to be made to the model to get this pivot to display the proper rows under their respective jusridictions.
Currently the pivot displays ALL tax detail rows for each jusridiction.
Image 1 was removed due to posting limits.
Image 2 is the pivot after adding in the tax type.
Image 3 is the data model, showing the relation between the invoice data and the tax data. There can be 1 to many tax rows per invoice row.
If this question has been asked and answered before please provide a link. I don't have the time to scan 1000+ posts on PowerPivot to see if they apply. I did go through 150 of them with no joy.

Merge rows with same Column A

I am new to VBA and from what I have seen it will be the best way to go about doing what I want to do. I have an excel spreadsheet with Column A being the name of a company and Column B being the state which it is in. Since companies are in multiple states there are repeated company names, I would like to make it so that Column B has a list of the states so that Column A does not repeat. I know that similar questions have been asked but like I said I am new to this and have never used VBA before so some of the code without an explanation is not all that helpful.
For example I would like to go from:
Company 1 | MI
Company 1 | IA
Company 1 | MD
Company 2 | MI
Company 2 | OH
To this:
Company 1 | MI, IA, MD
Company 2 | MI, OH
Any help would be greatly appreciated or suggestions of ways other than VBA would be appreciated.
I suggest you put both columns in the ROWS area of a PivotTable and ensure that has no subtotals and is in tabular format.
You may not need vba at all. One way to get the results you want is to put the following equation in Column C (assuming Company is in A and States are in B):
"=IF(A2<>A1,A2,"")"
Without the outside quotes. Then just drag the formula to fill to the bottom of the data. Also, if you use this formula, start the data on A2, as the formula will look at the cell above.
The D column is simply =B2.
The VBA code will follow this logic as well, if you still want to use VBA.