I am importing data from SQL 2008 view into Excel 2010 as a pivot table.
As you can see in the attached image,I have four columns named: 4,9,10,11. What I need is to rename these columns based on an if condition so that if the column name is 4 for example, it renames it "requested"
You have several options.
If the data is imported flat into a worksheet, and you choose to create the PivotTable on top of this worksheet, then you can simply add new columns with the logic you need using standard Excel formulas: =IF(E2="4","requested",IF(.... Then, refresh the pivottable and use the new column instead of Movement_Type.
Edit the connection properties of your SQL connection, change the Command Type to "SQL" instead of "Table", and use SQL syntax in the Command Text field to implement the logic you need.
SELECT *,
CASE Movement_Type
WHEN 4 THEN 'requested'
WHEN 5 THEN ...
END AS Movement_Type_Text
FROM MyView
Change the names directly in the Pivot Table (select the cell with "4" and type "requested". The Pivot Table should remember these names, when rearranging the content.
Import the data into PowerPivot and use DAX to implement any logic on textual fields, and change the column names to your preference.
Related
I have this table:
Is it possible to make a pivot table to present the information like this?:
Thanks!
Sure it's possible. As shown in your example, you just need to change the special character "✔️" by the number 1 using "ctrl + f". Then insert a Pivot Table with the data. And finally, create a new column named TOTAL and add the "=sum()" formula to count the items from each row. Something like that:
You are going to need to move this data from the word doc you are using into an Excel worksheet, in order to generate a pivot table.
format your data like this in Excel
To start out creating a pivot table, make sure that all rows and columns are selected and record (row) must not be obscure or elusive and must be making sense. Navigate to Insert tab, click PivotTable.
You will reach Create Pivot Table dialog box. Excel fills in data range from first to last selected columns and rows. You can also specify any external data source to be used. Finally choose worksheet to save the pivot table report.
The pivot table should appear. You can then populate this table with data fields which will pop up on the right hand side. Enable the fields you wish to compare in the pivot table report.
I am using a power query in Excel to get "data from folder" and transforming the excel file before "close and load." I thought the table loaded into the worksheet comes named for each column based on the header. However, this was not the case. Most of the articles I have read try to address a problem with using referenced names already defined. I am looking for "how to define name" within the power query.
Is it possible to define/create a range using the header name for each column in the table before "close and load?" I prefer to use "power query" to create reference/range names for each column instead of "name manager." For example, col A or col 1 with a header - Price; range - A1: A40 - set name as "Price" based on the header either automatically or manually within the power query editor. I would appreciate your comments.
Table created within Power Query
Table created as an output by Power Query after "close and load"
Table created does not use header as name for any columns
Table with name defined manually (outside of Power Query) for the first column "Date"
What you see in the last image is what I want to achieve using Power Query. Instead of defining the name for column in the Excel after "close and load", it would be nice to have names defined for each column in the Power Query itself before loading the data into worksheet.
I have an excel file that has a table imported from a txt in a sheet (using New Query). From that table I created a pivot table and some formulas like for example MAX().
I was told that for large files it is better to add the info to the data model as connection only (the data is not visible in a sheet).
No problem in creating the pivot and works great, but trying to do the formulas excel does not find the Table.
Before I could do something like this:
=+MAX(Table1[#[Column1]])
but know when I do MAX, the system does not find the Table1 I have loaded as connection only. Is there any way to relate a formula to data that has been added to the model as connection only?
Thanks.
In order to access data in the data model you can use "Cube functions" you can follow these steps:
1- From inside the "Manage Data Model" option, create a pivot table of your table
2- Customize the new pivot table according to your needs
3- Click the ribbon "PivotTable Tools" | "Analyze" | "OLAP Tools" | "Covert to formulas"
4- Optional: Merge the formulas in one
Remarks:
The functions (MAX, SUM, Etc.) must be defined in the Pivot Table.
Here is an screencast I created for you.
Reference: https://support.office.com/en-us/article/cube-functions-reference-2378132b-d3f2-4af1-896d-48a9ee840eb2
First Create a Data Model table then use
=MAXIF(Table1[Values],Table1[Labels],"a")
For eg - Say I have data in the following format -
Current Format
I would need the data to be formatted in the following format for ease of use -
Required Format
Of course the data contains a lot more records - I'm looking for an easy way to transpose data in this way for large sets of data.
Any help will be appreciated :)
What you want to do is called:
Unpivot:
Select the data and on the Insert menu choose Table
On the Data menu click From Table/Range
The query window will open. Choose the columns you need to extract. With your data the columns to highlight are "Type" and "Number of Cases"
On the Tranform menu choose Unpivot Columns
If the data looks right now, close the Query Editor (accepting changes).
Examples here: Unpivot Excel Data
This is very easy with PowerQuery. It is inbuilt for Excel 2016 and a freely available add in for Version from 2010 to 2013.
You would set your data up as a table excluding the first row which contains the text Number of Cases (Ctrl + T whilst bring up window to create table)
Then from the data tab (Excel 2016) or the Powerquery tab (earlier versions) select data from table and use your newly created table as source.
Highlight the last 3 columns and right click > unpivot columns
Double click in headers section and rename Attribute as Type and Value as Number of Cases
Top left select close and load to
Select table and load to new worksheet (or existing)
View result
I have a field in a SQL table which is of datatype 'money'. I'm loading the contents of this table to an excel destination using SSIS. Now the excel destination needs this money column to have a $ symbol i.e. basically format it to currency. It doesn't seems to work. I need to manually format the output each time. I can convert it using Derived column in SSIS and add a $ symbol; This would however convert the field to a string field and load it to excel which is not what I want.
Any inputs?
I tried adding a sample row with proper formatting and hiding the row in the excel destination before loading it. That doesn't work either.
Thanks.
Hidden sample row works for me. Here are the steps I suggest:
Create Excel file with column datatype defined as Currency with $ at
the start.
Add column name, e.g. "Total" In the second row put 0 in the cell.
Ensure that it is shown as "$0,00".
Create data flow with source as your SQL Server table and Excel
destination created based on your Excel file. Define mapping, etc.
Right click on created Excel destination, click "Show Advanced
Editor", go to "Input and Output Properties". Open "External
Columns" list and ensure that "Total" column is picked automatically
as currency [DT_CY]
Check this post as well: http://sqlserversolutions.blogspot.com/2011/10/numeric-gets-converted-to-text-in-excel.html