简体   繁体   English

从PowerQuery中的日期字段计算年龄和年龄段

[英]Calculate age & age buckets from a date field in powerquery

I am trying to create an ageing report from data in Power Query. 我正在尝试从Power Query中的数据创建老化报告。 I'm able to do the following if I pull the data into an Excel table: 如果我将数据拉入Excel表,则可以执行以下操作:

Age Column =(TODAY()-[@[Request Date]]) 年龄栏 =(TODAY()-[@ [请求日期]])

Ageing buckets =LOOKUP(J19372,{-60,2.1,5.1,7.1},{"0-2","2+","5+","7+"}) 老化桶 = LOOKUP(J19372,{-60,2.1,5.1,7.1},{“ 0-2”,“ 2 +”,“ 5 +”,“ 7+”})

However every time I refresh the data in the table from the query, I then need to copy the formulas down. 但是,每次我从查询刷新表中的数据时,都需要向下复制公式。 This is fine for me but I want it to be automatic for others that I send the file to. 这对我来说很好,但是我希望它对于将文件发送到的其他人来说是自动的。

Is there a way to do those calculations in PowerQuery? 有没有办法在PowerQuery中进行这些计算?

Sure you can. 你当然可以。 Except for retrieving today's date via Power Query, you need to refresh table. 除了通过Power Query检索今天的日期以外,您还需要刷新表。 Check one solution for banding here at Ken Puls blog: http://www.excelguru.ca/blog/2016/02/29/creating-a-banding-function-in-power-query/ 在Ken Puls博客中查看一种用于绑定的解决方案: http : //www.excelguru.ca/blog/2016/02/29/creating-a-banding-function-in-power-query/

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

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