如何将sql查询转换为dax查询

时间:2020-03-07 09:47:32

标签: powerbi dax daxstudio

我想将Power Bi中的sql查询转换为dax 我的桌子是:-

channel  advertiser yr
colors  pepsi   2019
colors  apple   2019
colors  pepsi   2018
colors  google  2018
colors  lux     2019

我尝试使用sql查询来查找新的广告客户:-

select advertiser from ads
where yr=2019 and advertiser not in --new ads
(select advertiser from ads
where yr=2018 )

我想将此查询转换为dax,我该怎么办? 我已经尝试过了:

EVALUATE
CALCULATETABLE (VALUES(adv[advertiser]),
adv[channel]="colors",
adv[year]=2019 && VALUES(adv[advertiser]) 
not (VALUES(adv[advertiser]),
adv[year]=2018
)) 

有人可以帮忙吗?预先谢谢.. !!

1 个答案:

答案 0 :(得分:0)

这将返回带有“新”广告客户的表格

EVALUATE
    CALCULATETABLE (
         VALUES(adv[advertiser])
        ,adv[channel]="colors"
        ,adv[year]=2019 
        , NOT adv[advertiser] IN CALCULATETABLE (
             VALUES(adv[advertiser])
            ,adv[year]=2018
        ))