简体   繁体   English

获取日期范围内第一个和最后一个度量值之间的差异-MDX

[英]Get difference between first and last measure values in a date range - MDX

I want to get the first value and last value of a selected measure between a specified date range. 我想获取指定日期范围内选定度量的第一个值和最后一个值。 Example: If I have a query that returns values between 10 Nov and 17 Nov, I want to subtract the value at 17 Nov from the value at 10 Nov. I tried using tail() and head() functions but it still not working. 示例:如果我有一个查询返回11月10日至11月17日之间的值,我想从11月10日的值中减去11月17日的值。我尝试使用tail()head()函数,但仍然无法正常工作。

SELECT MAX(t.Col) - MIN(t.Col)
FROM yourTable t

The statement returns the difference between max and min values on column Col. The statement can be further used as a subquery in various clauses such as where or select. 该语句返回列Col上的最大值和最小值之间的差。该语句可以进一步用作各种子句中的子查询,例如where或select。 If the column Col is a date-related one then the difference computed will reflect the number of days between min an max. 如果列Col是与日期相关的列,则计算出的差异将反映最小与最大之间的天数。

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

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