英文:
Power BI Rank partition by two columns
问题
I would like to rank Partition by two Columns I have a solution using Nested Filters but is there a more efficient solution?
I Tried the below.
Rank =
VAR t = tstRank[Entity Code]
VAR t2 = tstRank[Currency Ledger]
VAR r3 =
RANKX (
FILTER ( FILTER ( tstRank, [Currency Ledger] = t2 ), [Entity Code] = t ),
tstRank[NetSales]
)
RETURN
r3
Which has given the correct solution but is there a better way to achieve outcome?
英文:
I would like to rank Partition by two Columns I have a solution using Nested Filters but is there a more efficient solution?
I Tried the below.
Rank = 
VAR t = tstRank[Entity Code]
VAR t2 = tstRank[Currency Ledger]
VAR r3 =
RANKX (
    FILTER ( FILTER ( tstRank, [Currency Ledger] = t2 ), [Entity Code] = t ),
    tstRank[NetSales]
    )
RETURN
r3
Which has given the correct solution but is there a better way to achieve outcome?
答案1
得分: 1
我猜显而易见的是要 && 你的谓词以便进行一次表扫描,而不是嵌套迭代器:
Rank = 
VAR t = tstRank[Entity Code]
VAR t2 = tstRank[Currency Ledger]
RETURN
    RANKX (
        FILTER ( 
            tstRank, 
            [Currency Ledger] = t2
              && [Entity Code] = t 
        ),
        tstRank[NetSales]
    )
英文:
I guess the obvious is to && your predicates to have one table scan instead of a nested iterator:
Rank = 
VAR t = tstRank[Entity Code]
VAR t2 = tstRank[Currency Ledger]
RETURN
    RANKX (
        FILTER ( 
            tstRank, 
            [Currency Ledger] = t2
              && [Entity Code] = t 
        ),
        tstRank[NetSales]
    )
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论