Quick reshaping of table in Excel - excel

I'm new to using Excel/DAX.
Just wondering if there would be a quicker way to format the table
What I'm trying to achieve, is getting the above table to be formatted the same as below
Notice how in the lower table there is only 1 column for the year. I understand that this creates duplications of the countries in the first column
Any advice would really help.

Load the table into PowerQuery
Select the first 2 columns
In the Transform tab select from Unpivot other columns
There you go!
Btw, it's a typical ETL step (hence PowerQuery) called stacking a table from wide to long.

Related

Calculating Weekly Average in Excel 2019 using (DAX, Powerpivot, Powerquery)

I have data in my table
I want to calculate weekly average. Like this
I can acomplish this by excel formulas but I am not fan of formulas. I need DAX, powerquery or powerpivot solution to automate the task.
The attached workbook uses power query to get to your desired output.
Steps
Replicate the date column
Transform the replicated date column to start of week
Group Rows by StartofWeek; create three additional columns
Close & Load as query conneciton only
Create a second Table query by repeating steps 1,2
Merge queries, joining on StartOfWeek column
Expand the WeeklyAvg columns and show the averages that you desire
This could also be done differently via DAX. Please let me know if this answers your request or if you have additional comments/suggestions. Thanks!
https://1drv.ms/x/s!AmcGUE_vrclQ7yIG6ZGnErO4m2LT?e=flnqio

How to get the counts/frequencies of values in a table?

I have the problem that I need to get the number of occurences / the counts or frequencies of values in a table. However, I cannot give the categories before, so in opposite to countif I cannot specify a specific value, as this needs to be done from the table. I have a whole table, not just a column. The picture shows a reduced example:
The result I need would look like the following (I counted manually, hope I did not do a mistake):
It is not needed to calculate empty cells.
For the starting point I am ok with not specifiying if there is a difference between lowercase and uppercase (so L and l for example). This can be calculated separately or as the same. Later on it would be good to be able to choose this as an option. (I could use lowercase function and refer to this column and fill another column with the values, however the original data is way too large.). My problem is now that I am not able to do this "simple" task. I found a solution for a single column, using a matrix function with countif:
{=countif(A21:A27;A21:A27)}
This does not work for a whole table. My original data is too large to do any task manually and repeat this for each column or rearrange the data manually from table to one single column.
Unfortunately I am limited to Excel and/or Excel VBA. I cannot use any other tool. I am happy with an excel solution, if there is a way to do it in VBA I am also very ok with it, however for this I cannot give a proof that I tried it, because I don't have an idea how to program this and I am not advanced enough in coding VBA.
Through PowerQuery
Sample data:
My Excel is in Dutch so excuse me for making some translation errors. It should still point you in the right direction:
1: Select all data > Data Tab > Transform > From Table/Range > Choose No headers
2: In PQ select all 4 columns > Transform Tab > Unpivot all columns
3: Select value column > Transform Tab > Pivot Table > Ok
4: Select all columns > Transform Tab > Unpivot all columns again
5: Exit PowerQuery and confirm to save your edition.
Result:
Will exclude empty cells
Will distinguish between upper and lower case
Analyzing this data is easiest if it is in one column. You can use Power Query (Get & Transform) for that. Load the data into the Power Query Editor, keep only column 1. Repeat and keep only column 2, repeat for columns 3 and 4.
Next, append the columns, so you have one column of data.
Now you can either load this data into the data model and THEN it's easy to build a pivot table. Blank cells can be removed in the Power Query or by filtering the pivot table.

How to Transpose Columns to Rows and add redundant data

I'm trying to find a solution in Power Query to transpose Table 1 into Table 2 (in the link). I have seen other transpositions on this forum but not one quite like this where I need redundant data to be added. Does anyone know a way to do this type of transposition using Power Query or Excel in general?
How can I transpose Table 1 to look like Table 2?
Looking for suggestions...
In the Query Editor, select the columns for your stores and then on the Transform tab of the ribbon, select Unpivot Columns > Unpivot only the selected columns.
Here is a snip of a data table (blue) and the unpivoted result below (yellow).

Add two columns in Excel Pivot Table

I'm running into a bit of a problem which I'm guessing there exists an easy solution to which I've overlooked.
I'm trying to add a column to a pivot table that is the sum of two other columns in the pivot table. All of the documentation that I've seen has told me how to make a calculated field based on the columns in the original data set.
I've added a column to the right of my pivot table that does exactly what I want - summing columns B and C in the pivot table:
Unfortunately this column is not considered as part of the pivot table so pivot charts do not include it.
There HAS to be an easy solution to this that I'm overlooking. Does anyone know what I'm doing wrong?
Best regards,
MoarCodePlz

Issues grouping in excel?

I'm having a little bit of trouble grouping dates in excel. I have created a pivot table that groups a bunch of dates between 3 months together. However, I want to take advantage of the refresh ability of pivot tables--the idea in which when you refresh your pivot table, it will update to whatever you added or took away from the source of data your pivot table is based on.
However, when I grouped the dates between three months together, I noticed if I don't add a date that exactly corresponds to the dates within the grouping, the picot table does not add that entry into the pivot table. For example, if my grouping had the following dates (between May and July) in it:
5/21/2013, 7/18/2013, 6/8/2013
And in my source data spreadsheet had the following date added to it:
5/2/2013
5/2/2013 would not be added to that specific grouping in the pivot table because it is not exactly like the other dates as stated above. I want it so that I can group all dates from 5/1/2013 to 7/31/2013 inclusively as opposed to the dates in the original grouping. Would anyone have an idea on how to do so? Thanks!
http://www.datawright.com.au/excel_resources/expanding_pivot_tables.htm
im curious as to how you are currently grouping them without adding new ones, there may be a way to work with what you already have especially if you are willing to incorporate some VBA
Provided your source 'dates' are not text Excel should be able to cope.
I fear (hope?) we were at cross-purposes about which "Group" to use. I meant the one that pops up (as on the left below) when right-clicking one of the Qtr headings in the PivotTable.
If you have access to add additional formulas in the data you could just calculate "quarter" in an additional column (reference here)
How can I obtain the year quarter from a date?
I tend to always make my groups in the rows of data like this, rather than attempt it using pivot groups. For example, you might also extract "year" with = year(A1) in the rows - so you can easily add it as a pivot row item later for grouping. If your data source is properly formatted as an excel 2007 "table" these kind of formulas will fill themselves downward when you paste new data.

Resources