我是 DAX 的新手。
假设我有一张看起来像这样的桌子:
Table A:
status delivered sold
late 10 50
late 20 300
early 5 500
假设我正在使用这个 SQL 查询:
with cte_1 as (
select
status, count(*) as [row_count]
from [table a]
group by [status]
having count(*) > 1
)
select *
from [table a] as p1
inner join [cte_1] as p2
on p1.[status] = p2.[status]
什么是 dax 等价物?
答案 0 :(得分:1)
SQL 查询返回表 A 中状态至少在表中出现两次的行,并将状态相同的行数相加。在Power BI中我们可以写一个计算表,将相同状态的行数相加,然后过滤掉计数小于2的行
Result =
FILTER(
ADDCOLUMNS(
'Table A',
"row_count",
CALCULATE(
COUNTROWS( 'Table A' ),
ALLEXCEPT( 'Table A', 'Table A'[Status] )
)
),
[row_count] > 1
)