计算YTD,MTD,WTD,Power BI中的交易计数
我有1行的1个桌子。看起来像这样:
------------------------------------------------
StoreId| PostingDate | SalesAmt
MAIN | 2021-02-04 | 100
WEST | 2021-08-11 | 15
WEST | 2021-09-11 | 36
MAIN | 2021-11-11 | 78
MAIN | 2021-04-11 | 56
------------------------------------------------
不久之后...
现在,我想在Power BI中作为桌子产生以下内容:
--------------------------------------------
StoreId| YTD | MTD | WTD | TransactionCount |
WEST |5,447| 800 | 74 | 1,475 |
MAIN |4,500| 421 | 15 | 1,855 |
--------------------------------------------
我该如何实现?我对此非常陌生,所以我不知道该怎么做。 我一直在阅读DAX和Power查询,但也许DAX适合此?
I have 1 table with multiple rows. It looks something like this:
------------------------------------------------
StoreId| PostingDate | SalesAmt
MAIN | 2021-02-04 | 100
WEST | 2021-08-11 | 15
WEST | 2021-09-11 | 36
MAIN | 2021-11-11 | 78
MAIN | 2021-04-11 | 56
------------------------------------------------
And soon and so forth...
Now I want to produce the following in the Power BI as Table:
--------------------------------------------
StoreId| YTD | MTD | WTD | TransactionCount |
WEST |5,447| 800 | 74 | 1,475 |
MAIN |4,500| 421 | 15 | 1,855 |
--------------------------------------------
How can I achieve that? I am very new to this so I don't know how to do it.
I have been reading DAX and Power Query but maybe DAX is suitable for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以为您的数据看起来像这样。我添加了2022年的数据。
另外,我假设没有未来的日期,观察结果是过去发生的交易。
Table
日历表
计算的 在下面工作,您需要创建一个日历表。
从
表的第一次日期
到今天。如果您的日历表不同,时间智能函数将无法工作。
并将
日历
表标记为日期表。销售金额
WTD
假设您的一周在星期一开始。
MTD:
YTD
I assumed your data looks like this. I've added data for the year 2022.
Also, I'm assuming there aren't future dates, the observations behave as transactions that happened in the past.
Table
Calendar Table
For the calculations below to work, you need to create a calendar table.
It goes from the first date of
Table
until today.If your calendar table is different the time intelligence function will not work.
And mark the
Calendar
table as a Date Table.Sales Amount
WTD
Assumes your week starts on Monday.
MTD:
YTD