简体   繁体   English

使用(DAX、Powerpivot、Powerquery)计算 Excel 2019 中的每周平均值

[英]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.我可以通过 excel 公式来完成这个,但我不喜欢公式。 I need DAX, powerquery or powerpivot solution to automate the task.我需要 DAX、powerquery 或 powerpivot 解决方案来自动执行任务。

The attached workbook uses power query to get to your desired output.随附的工作簿使用电源查询来获取您想要的 output。

Steps脚步

  1. Replicate the date column复制日期列
  2. Transform the replicated date column to start of week将复制的日期列转换为一周的开始
  3. Group Rows by StartofWeek;按 StartofWeek 分组行; create three additional columns创建三个额外的列GroupBy 截图
  4. Close & Load as query conneciton only仅作为查询连接关闭并加载
  5. Create a second Table query by repeating steps 1,2通过重复步骤 1,2 创建第二个表查询
  6. Merge queries, joining on StartOfWeek column合并查询,加入 StartOfWeek 列合并查询
  7. Expand the WeeklyAvg columns and show the averages that you desire展开 WeeklyAvg 列并显示您想要的平均值

This could also be done differently via DAX.这也可以通过 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 https://1drv.ms/x/s?AmcGUE_vrclQ7yIG6ZGnErO4m2LT?e=flnqio

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM