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

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

Related

PowerPivot and dax formulas

new to this but i need some help with PowerPivot. I have recently created a PowerPivot to pull through 3 different excel documents that will be updated automatically each week with new data. They all have at least 2 of the same unique codes to be able to link them together.
I have managed to link all the files together and create a pivot to show the relevant information from each file under one pivot. my problem is now I need to add some formulas that relate to the actual data in the pivot.
Q1:I need the average of the last 4 weeks of data from the pivot but i need the formula to be able to shift when the new weeks are added.(if there is a way to do this with a dax formula that would be very good as well.
I have dates and weeks in the data set.
Basically I'm after knowing if I am able to create formula next to my pivot that will shift the the data grows or changes.
currently the pivot looks like the picture attached.
I have also attached a pic of the data
Q2:How do i get the pivot to only show me the last 4 weeks nothing else
if anyone has any suggestions on how I could get any of this to work that would be amazing.
Thank in advance power pivot datapivot table
Q1: what i have tried -I have tired to add formula next to the pivot but it breaks or gets deleted when the the pivot updates
Q2: I have created a slicer and I manually change it

Quick reshaping of table in 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.

Converting table with columns of monthly data into single row of monthly data

I have a large table of sales data with multiple columns of descriptions and then columns for the each of the 12 months. I would like to keep the multiple descriptor columns but combine the monthly data into one column.
I use excel for mac and not a regular user of vba. I know it can be done with formulas like offset but I cant figure it out. Thanks for your help.
In Excel parlance: you want to "unpivot" the month columns. A simple task in PowerQuery which you "should" have available.
This is the same thing as "normalising". You'll want to use VBA and this SO question provides a solution to the question I just begged.
Fast Way to Normalize Data with VBA (Excel)

Excel Power Pivot Time Averages

I am trying to calculate averages for time. I am using a set of data that allows me to use a pivot table to average a column formatted as "Custom h:mm:ss" or "0:13:44" within an Excel workbook.
When I import that same data into Power Pivot and attempt to do the average it tells me that the calculation cannot be completed because the data type is not supported. I noticed that the same data becomes formatted as "12/30/1899 12:13:44" in Power Pivot. Even when I change the format of the column in Power Pivot to "h:mm"ss" it will not let me do the calculation.
I am trying to figure out why the format is calculable in the Excel workbook and why it changes when I use Power Pivot. I want to be able to link to a database and create a pivot table to share. Any help would be greatly appreciated.
It might be being imported over as a text string. You can probably avoid this by converting the cell format to "number" before it is imported over.

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