简体   繁体   English

在数据透视图中按月最佳地对日期进行分组

[英]optimally grouping dates by month in pivot

My data is organized by: Day, Month, Year and I'd like it to be grouped by Month, Year so as to properly have it summed up in a pivot. 我的数据是按以下格式组织的: Day, Month, Year ,我希望Day, Month, Year对数据进行分组Month, Year以便正确地汇总数据。

However, when setting the date to mmm, yy format, the pivot still acts as if there are individual days, so my pivot filter has 30 cases of Apr, 16 . 但是,将日期设置为mmm, yy格式时,数据透视表仍会像有个别日子一样工作,因此我的数据透视表过滤器有30例Apr, 16

If I do this by converting date to text with =text(B2,"mmm, yy") then the chronological order is lost in the pivot and all I get is some phony alphabetical order by months, and using "mm" instead is no better (the data gets ordered 1, 10, 11, 12, 2, 3...9 ). 如果我通过将日期转换为=text(B2,"mmm, yy")来执行此操作=text(B2,"mmm, yy")时间顺序丢失了数据透视表,而我得到的只是几个月的虚假字母顺序,而使用“ mm”则不是更好(将数据排序为1、10、11、12、2、3 1, 10, 11, 12, 2, 3...9 )。

My current formula is =date(right(B2,4)&left(B2,2),1) 我当前的公式是=date(right(B2,4)&left(B2,2),1)

where B column has =text(X2,"mm - yyyy") 其中B列=text(X2,"mm - yyyy")

where X column has dates by day X列中有日期的地方

I'm seeking a way to do this without helper columns and seemingly redundant operations like the formula below: 我正在寻找一种无需助手列和看似多余的操作(例如以下公式)的方法:

=date(right(text(X2,"mm - yyyy"),4),left(text(X2,"mm - yyyy"),2),1)

=date(right(text(X2,"mm - yyyy"),4),left(text(X2,"mm - yyyy"),2),1)

事实证明,这是解决此问题的最简单方法,因为将它们全部按1 / mm / yyyy排序可以将它们组合到一个数据透视表中,同时将格式更改为“ mm-yyyy”可以使我的数据透视表日期按预期显示

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

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