DAX的案例陈述 [英] Case Statement in DAX

查看:160
本文介绍了DAX的案例陈述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


早安



我正在尝试获取每种产品的特定描述类型的最大日期。我知道如何做这个SQL,但有人可以指导在DAX中写它



选择产品,



max(描述在('玩具','表','衬衫'和类型<>'不需要'然后日期结束时)OVER(按产品分类)为XYZ_Date,



max(描述在('Soap','Shampoo','Shoes'然后Date结束时)OVER(PARTITION BY Product)作为XYZ_Date来自TableName





谢谢 





解决方案

我找到了自己的答案。可能是如果有人想要在DAX中实现count / max / sum / min / avg,那么它可能很有用。



ABC_DATE = CALCULATE( MAX([日期]),

       ALLEXCEPT([Product]),

       [说明]在{" A"," B"," C"}}中)





Good Morning

I am trying to get maximum date for certain description type for each product. I know how to do this SQL but someone can one please guide to write it in DAX

select Product ,

max(case when Description in ('Toys','Table','Shirts' and Type<>'Not Needed' then Date end) OVER(PARTITION BY Product) as XYZ_Date ,

max(case when Description in ('Soap','Shampoo','Shoes' then Date end) OVER(PARTITION BY Product) as XYZ_Date from TableName

Thanks 


解决方案

i found my own answer. May be it could useful if some one wants to do achieve count/max/sum/min/avg over partition by in DAX

ABC_DATE = CALCULATE(MAX([DATE]),
           ALLEXCEPT([Product]),
         [Description] in {"A","B","C"})



这篇关于DAX的案例陈述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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