Calculated PivotFields in the Excel Javascript add-in API - excel

I'm attempting to create a pivot table through the Excel Javascript API, based off of some old code. With VBA, I could write something like
Worksheets(1).PivotTables(1).CalculatedFields.Add "PxS", _
"= Product * Sales"
to add a calculated field to a pivot table. I can't find an equivalent through the excel javascript api and I'm not sure if it just hasn't been added yet, or if I'm missing a feature somewhere.
The closest thing I've found is ShowAsRule, but I don't think the functionality there is equivalent (you can't use a custom formula)

can you check the doc of Add rows and columns to a PivotTable segment in the url https://learn.microsoft.com/en-us/office/dev/add-ins/excel/excel-add-ins-pivottables ? A workaround is creating a new column with like C=A*B, and add C directly

Related

Excel - set up parametrized data source

I want to filter data from an external data source.
I have an Excel sheet coming from a MySQL data source ([IN]).
Now I want a new sheet [FILTERED] having data from the sheet [IN] filtered on some user parameteres defined in sheet [PARAM]: {appointmentDay} and {idSite}
Ideally the sheet [FILTERED] should be updated automatically if the filters {appointmentDay} and {idSite} would change.
I suppose there should be a very easy solution, but unfortunately I don't find anything going into this direction.
I found a solution here:
How to use parameterized query in Excel using column as parameter?
In short:
1) you create a data source using "Microsoft Query"
2) in the where you use ? as placeholder for parameters
3) in the connection properties you define where to look for the paramters

Updating a table from a power query changes formula reference

Saw this was previously asked here on SO and had no solution and I can't find a solution through Google either.
I have a workbook with a tab called "Data" containing a table which is updated via a power query and another tab called "Calcs" with formulas referencing the cells in the table from "Data". When I refresh the table, it pulls data via the power query, but when it's done, the formula references change.
For example, before the refresh, I'll have formulas like this in the "Calcs" tab:
=COUNTIFS('Data'!$A$2:$A$26886,$A1060,'Data'!$K$2:$K$26886,'BY CAT'!$B1060)
After the refresh, the references for column A only change to
=COUNTIFS('Data'!$A$10242:$A$26886,$A1060,'Data'!$K$2:$K$26886,'BY CAT'!$B1060)
And it results ina #VALUE! error message.
How can I prevent Excel from creating this reference shift?
You might be able to get around this by using full column references:
=COUNTIFS('Data'!$A:$A,$A1060,'Data'!$K:$K,'BY CAT'!$B1060)
Full column references aren't always a good idea, but it might just work in this case.
Edit:
Table column references would be ideal, TableName[ColumnName]. These should work given that you are reading from a power query generated table.

Is it possible to load List of values in excel using VSTO web add-ins using office.js

I am developing a excel add-in using office.js, that populates table data in excel sheet. Add-in allows user to update table column details, but I want to display list of reference values rather than free text.
Example for scenario is given below.
Table displayed in excel will have two columns Column 1 And Column 2, I will have reference data as shown in reference table, When user want to update column 2 I want user to select only allowed values, but I don't see any options available in office.js library. Please guide me If any of you have any suggestions to achieve my need.
I am loading table using offfice.js objects as given below
var data = serverTableObjectAsArray;
var officeTable = new Office.TableData();
officeTable.addHeaders(data[0]);
officeTable.addRange(data);
Data validation was just introduced in 'beta' version. It is not available in the production version. You can check out the details in range.validation API here

CSV Connection into Named Table not Range

If you make a data connection to another Excel file or an Access table it will import that data into excel as a Table. This is great! But when I do the same with "From Text" and choose a CSV, it loads no problem, but it loads as a RANGE not a TABLE. This is highly frustrating as I NEED it to be in the table format so that I can take advantage of the dynamic column names.
Am I missing a tickbox somewhere? I'm not opposed to using VBA but it really seems odd that Excel can't do CSV to Table so I'm hoping for a native solution.
I should mention that if it's a VBA solution, it CANT break the workbook. So if I'm doing something like:
=SUMIFS(CSVDATA[SalesDollars], CSVDATA[RepName], "BOB")
It will still work after refreshing.
So you can get around the 'data connection' not creating a table by downloading the MS Excel 2010 plugin (from Microsoft) called Power Query. It's free and is a default feature in MS Excel 2013.
It will allow you to choose to create a Power Query Table from External Data >> From File >> From CSV
Upon doing this, it will create a named table for you and a Power Query object attached to the table. You can use the table itself the same way you normally would - with the Columns as references for formulas.
For instance, the default table that I just created using the steps above was auto-named: Table_ExternalData_1
I can then select it using the normal method in formulas:
=Table_ExternalData_1[Column2]
etc...
Hope that helps.

How to view a pivot table with actual column values like access in excel

I've tried searching this but couldn't find an answer because of the wording of the question. If it's been asked before please point me in the right direction.
I have the same exact data in Excel and Access, however, the pivot tables are viewed differently as shown below:
Excel view and data
Access view, same data
As you can see the pivot table in access has the actual values (Y, N) whereas in excel it sums up the values. I want excel to display the actual values like Access and not the sum.
I'll be switching over to Office 2013 soon and need to know how to do this in Excel 2013 since pivot tables were removed from Access 2010 in Access 2013.
I have also tried adding data to the columns section but doing so gave a harder to follow and different view as shown below:
I think this is what you are trying to do....
Looks like you will need an extra column in your table showing boolean values for yes/no as 1/0 for both house and car
Then, use those two new columns as your Sum of Values in the pivot table. Right click on the pivot table, go to options, and make sure that you have 'empty cells' set as blank. Then, for each value, you need this custom format
[>=1]“Yes”;[=0]“No”;
Don't copy and paste it in - it doesn't work (not for me anyway). Type it in manually.
I got the info from here (which probably explains it better) http://chandoo.org/wp/2012/05/07/displaying-text-values-in-pivot-tables-without-vba/

Resources