Add column to Excel Power Pivot Table based on slicer seection - excel

I have an Excel Power Pivot Data Model with one table of about 3m entries. In one of my sheets I have multiple slicers that I combine to select entries that fit specific criteria.
I would like to add a column with a value that comes from a cell in the sheet, but only when the entry was part of the selection. For example: when the value in the cell is 1, the selected entries will get "1" in the added column. After that the number in the cell could be set to 2 and a new selection could be made. The new selection will all have "2" in the same added column.
I have been trying to make this work running a macro and DAX, but it can't get it to work. Anyone any ideas?

You can use the VBA I've previously posted at Converting multiple variables into values with excel pivot tables or power pivot to do that. It requires you to make up a 'harvester' PivotTable containing just the columns you want to swap out, so that you can then create a slicer from which to trigger the code.
You can also write a conditional formula in DAX that uses a harvester measure. Something like https://powerpivotpro.com/2012/11/one-slicer-to-control-them-all/ (and plenty of other examples on Google)

Related

Get slicer selection of a data table

I have been struggling with this issue in the past days and haven't found yet any solution.
I have a simple table (not a pivot table) and some slicers attached to it. I want to 'simply' show selected value/values of the slicer in a cell. It implies of course to make the cell update automatically according to the selection.
Some of the solutions I found suggested using two pivot tables, one main for the regular data and the other hidden to capture the selected filters. The problem is that I am not working with a pivot table, but rather a simple table.
I also tried getting distinct values of the table column, but I couldn't perform it properly without getting the hidden values of the filtered table too.
Is there any way in Excel to do this simply?
Thank you!
You can follow the below steps to achieve your result
You will have to insert a serial number column in your table
After that insert the below formula above the header or anywhere you want to display the selected value
The formula in C2 is
=INDEX(Table1[Data 2],SUBTOTAL(5,Table1[S.No]))

Excel Creating New Sheet with Summed Data from related sheet

Lets say I have the following on a sheet.
By some means, I want to either replace this, or preferably, create a new sheet, with the following data. Notice, that PO# is out of the picture, and a summation is done on rest of the fields. Is there a way to easily do this?
The end result has to be data in excel grid like below (preferably on a new sheet). This can possibly be some macro or some other technique I can use to easily create this....
You can easily do this with SUMIFS() or a Pivot Table.
For SUMIFS() the below equation will give you the sum for W.PS123 Product A. Modify as needed for your other criteria by swapping AR and product number (both housed in quotes in below formula, you can also set these equal to a cell range that contains desired criteria).
If you have a set number of "ARs" and Product Numbers, you will only need to build this table once and the equations will automatically update as your raw data changes.
=SUMIFS(C:C,A:A,"W.PS123",E:E,"A")
Alternatively, you can build a pivot table and just refresh this every time your data updates (or create a worksheet_change macro to refresh the table automatically when your data changes).
To build your pivot:
Highlight your table array (In your example, Col A-D)
Insert > Pivot Table
Drag AR to Rows
Drag PRODUCT to Rows (Below AR)
Drag QTY to "Values" and change the field to "Sum" rather the default count
Format to taste

Filter column for substring and return max of adjacent cells -- Excel 2013 (no macros)

I would like to obtain the max call time that was on each day, the average of all the calls that day, and any calls that exceeded 20 seconds.
Due to the security policies at work I am limited to the formulas provided by excel, I can't use macros or VB (otherwise I would just write something suitable). I don't have much experience with excel, so I apologize if this is a simple one. I have tried to find ways to search and return a subarray that I could easily manipulate, but it seems the only way to do that is with macros. Currently I think I can use VLOOKUP, but I don't really understand enough about it know if I can use this with another function.
Essentially, if there is a formula or a combination of formulas that I can use that will allow me to collect all data from column B that shares the same values in column A, I could nest that in the formulas I need to calculate the data.
Any help is appreciated!
This can be done with a pivot table in just a few clicks.
First, turn the source data into an Excel Table object, by selecting one cell in the table and then using Insert > Table or Ctrl-T. Add a helper column for the calls over 20 seconds. Let the column be "long calls" and the formula
=IF([#Duration]>TIME(0,0,20),1,0)
Then, with a cell of the Excel Table selected, click Insert > Pivot Table. (The pivot table is now linked to the Excel Table object and when more data is added you can refresh the pivot table without having to change the definition of the source data.)
Drag the Day field into the rows area and the Duration field into the Values area. Right-click any of the value results in the pivot table, and in the Value Field Settings dialog select Max. Then click on Number Format button and set the custom number format of hh:mm:ss. Confirm all dialogs.
If you want to format the date, right click any of the visible dates in the Pivot table, select Field Settings, click Number Format and then set the custom format ddd.
Drag the duration field into the values area again and set its calculation method to Average.
Drag the "long calls" field into the values area.
Hide the Grand Totals via the Pivot Table tools Design ribbon command.
Now you can add more data to the table in columns A to B, right click the pivot table and select refresh.

Excel: Pivot Table Filtering Using VBA/Slicer?

Gold star for whoever solves this! :)
I have a pivot table that has data from various attributes attached to unique ID numbers from an OLAP cube report. When I select ID# as a pivot field and all the corresponding attributes ie: Name,age,etc I end up getting about 10k ID's with 10k corresponding attribute values. I have a list of 3k ID#'s which I want to filter my report by. What is the best way to do this?
Simple example: Pivot table displays ID# 1,2,3,4,5 and corresponding attributes such as name,age,etc
I want to filter ID#'s from a column of values I have in another worksheet for example the column in other worksheet would have ID#'s 1,2,3 (Which in theory would omit values 4 and 5 from pivot)
(Keep in mind I am dealing with thousands of rows this example is made simple just for explanation)
I thought a VBA slicer combo might work, but I have no clue how to set up a slicer so when it is created it has only values selected from a column of values.
In my example VBA slicer will have ID#'s 1,2,3 selected upon creation or an easy way to select multiple ID#s from a list or something as I can't feasibly click through 3k values
Possible Solutions I Brainstormed
I was also thinking maybe just a VLOOKUP or something that will pull ID#'s against the column and also bring all corresponding attributes? The thing is I like the cube report being dynamic and updating with the slicer.
I then also thought to create a slicer based off of another pivot table which is composed simply of a header of ID#'s and lists ID# 1,2,3 I created in another worksheet and try and use that simple slicer against the OLAP cube, but the issue is the slicers have different connections and they can't overlap. :(
Any and all help is much appreciated!!! :)

Preparing Excel Pivot Table

-
I have a tabular data with values as in picture. I created a pivot table in excel 2007 .How can I get count value of each up/Down for date specified. I tried to by making one column row and other as values but it would not work.
The result would be:
A better solution is to use a countif function on a second tab. something like
=COUNTIF(Sheet1!A:A,"UP")
and
=COUNTIF(Sheet1!A:A,"DOWN")
and copy it across the range of dates.
If you can format your data differently to look like this
Then the pivot table becomes easy withthe following settings

Resources