DAX去年至今

编程入门 行业动态 更新时间:2024-10-26 20:28:07
本文介绍了DAX去年至今的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以我知道这个问题已经问过几次了,我虔诚地研究了不同的方法,但是我仍然不太明白为什么我得到的结果不正确。

So I know this question has been asked a few times, and I've religiously looked over different approaches, however I still don't quite understand why I'm getting an incorrect result.

案例:我有从〜2016-> 2019年的销售数据(直到2/18/2019)我有一个度量来显示年初至今,但是我正在寻找一个度量迄今为止的最后几年(在这种情况下为第18个)。

Case: I have Sales Data from ~2016 -> 2019 (up until the 2/18/2019) I'm have a Measure to show me the YTD, however I'm looking for a measure for Last Years to date(the 18th in this particular circumstance).

现在,我有:

Total Sales LYTD = CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( FILTER ( VALUES ( Sales[Completed Date] ), Sales[Completed Date] <= MAX ( Sales[Completed Date] ) ) ) )

对我来说,逻辑很有意义,但我敢肯定我错过了一些东西,看来它在整个2018年吸引了我, m寻找01/01/2018-> 2/18/2018

The logic to me makes sense, but I'm sure I'm missing something, has it appears it's grabbing the ENTIRE total of 2018 when in reality i'm looking for 01/01/2018 -> 2/18/2018

动态地上传新的销售数据

This is going to be dynamically uploaded with new sales data

我缺少什么?

推荐答案

不确定我是否了解您的表设置,因此让我们看一下这种情况,希望对您有帮助。

Not sure I understand your table setup so lets look at this scenario and hopefully it helps.

假设您有两个表Sales和Calendar中的数据,并且日历和sales表之间存在1:*的关系。然后我将这样写:

Suppose you have the data in two tables, Sales and Calendar, and there's a 1:* relationship between the calendar and the sales tables. Then I would write the measures like this:

SalesToDateThisYear = calculate( Sum(Sales[Sales]); Calendar[Year] = Year(Today()) )

and

SalesToDateLastYear = var dateLastYear = Today() - 365 return calculate( Sum(Sales[Sales]); Calendar[Year] = Year(dateLatsYear); Calendar[Date] < dateLastYear )

两个过滤器参数与逻辑AND组合。因此,只包括从去年第一天到去年今天的日期。

The two filter arguments are combined with a logic AND. So only dates from the first of last year to today's date last year will be included.

如果要使用SamePeriod函数,您可能可以编写如下内容

If you want to use the SamePeriod-function you can probably write something like this

SPLY = calculate = Sum(Sales[Sales]); SamePeriodLastYear( Filter( Values(Calendar[Date]); Calendar[Date] >= Date(year(today()); 1; 1) && Calendar[Date] < Today() ) ) )

SamePeriod函数采用一组日期(今年)并将其转换为去年的日期。

The SamePeriod-function takes a set of dates (this year) and converts them to dates last year.

欢呼声

更多推荐

DAX去年至今

本文发布于:2023-10-30 11:28:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542722.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:去年   DAX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!