我正在尝试解决Power BI中的以下问题: 我有一个包含销售的事实表,还有一个供客户使用的维表。我为客户维度创建了几个计算列:
现在,我必须计算每个客户的“活动连胜”时长,该时间应显示客户购买商品的第一天。连续出现条纹的时间间隔不能超过365天。
示例:
于2018年1月1日首次购买;从2019年9月2日起第二次购买-> Active Streak自2019年9月2日起
于2018年1月1日首次购买; 2018年12月3日第二次购买; 2019年6月4日第三次购买->自2018年1月1日以来活跃
因此,基本上,我想在365天以上的间隔之前找到最后一次购买。
任何关于如何使用DAX实现此目标的想法将不胜感激。
编辑: 相关表如下:
dCustomer (Customer Dimension):
[ContactSKey] (Primary Key)
[Contact Name]
[Contact City]
[Contact Insert Date]
...
[Last Purchase] (Calculated Column)
[Average Days between Purchases] (Calculated Column)
[Active Customer] (Calculated Column)
dSalesOrderInsertedDate (Date Table):
[DateSKey] (Primary Key)
[Sales_Order_Inserted Date] (Date Column)
[YearNumber]
...
fNoSalesDocument_Order (Fact Table):
[NoSalesDocumentSKey] (Primary Key)
[InsertedDateSKey] (Foreign Key of Date Table)
[ContactSKey] (Foreign Key of Customer Table)
[Item Amount]
[Item Quantity]
...
如果您需要更多信息,请告诉我。谢谢!