首页 > 解决方案 > 在 Power BI 中将计算列更改为度量

问题描述

我想将计算列更改为度量,以便我可以使用切片器更改 Power BI 中的度量。

我想将 table1 的值和 table1 的免赔额与 table2 的阈值(下一行)进行比较,并总结 table1 的值。

样本数据:

Table1
Value    Deductible
51000    45000      
56000    57000      

Table2
Threshold    The Result to calculate
50000        51000         
55000        107000    
60000           

输出是表 2 中的第二列。

计算列的代码是:

value_below_threshold = 
VAR CurThreshold = table2[Threshold]
VAR NextThreshold = table2[Threshold] + 5000
VAR __RelevantRowsTable2 =
    FILTER (
        'table1',
         'table1'[value] < NextThreshold
            && 'table1'[Deductible] < NextThreshold
    )
VAR __RelevantRowsTable3 = 
    FILTER (table2,
        contains(
        'table2',
        table2[Threshold],
        NextThreshold)
    )
RETURN
    CALCULATE ( sum(table1[value]), __RelevantRowsTable2, __RelevantRowsTable3  )

但我不知道如何将此计算列更改为度量值。有人可以帮我解决这个问题吗?非常感谢!

标签: powerbi

解决方案


推荐阅读