如何计算DAX每年的新客户数量 [英] How to calculate the number of new customers every year in DAX

查看:94
本文介绍了如何计算DAX每年的新客户数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须计算每年的新客户数量.这是我的表格,

I have to calculate the number of new customers for every year. Here is my table,

这是预期的结果.

棘手的部分是,我不必仅计算两年之间的差额,我必须知道是否存在从一年到另一个离开的客户,然后跳过它们进行我的计算.结果仅包括新客户的数量.我希望我能说清楚自己.

The tricky part is that I don't have to only count the difference between two years, I have to know if there are customers who left from one year to the other and then skip them to my calculation. The result only include the amount of new customers. I hope I made myself clear.

谢谢.

推荐答案

您可以使用 COUNTX 函数计算当前年份中上一年没有的客户数量:

You can use the COUNTX function to count how many customers in the current year were not in the previous year:

New Users = 
    VAR CurrentYear = MAX(Customers[Year])
    VAR OldUsers = CALCULATETABLE(
                       VALUES(Customers[Customer]),
                       Customers[Year] < CurrentYear)
    RETURN COUNTX(
               FILTER(Customers,
                   NOT(Customers[Customer] IN OldUsers)),
               Customers[Customer])

这篇关于如何计算DAX每年的新客户数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆