Powerbi 显示测量的基础数据
我在power BI中有一个表,其中包含有关配方和成分的信息,如下所示:Powerbi 显示测量的基础数据,powerbi,dax,Powerbi,Dax,我在power BI中有一个表,其中包含有关配方和成分的信息,如下所示: 我只需要获得至少2份食谱中出现的食材数量,这部分我可以通过以下措施进行管理: CountRecipe=DISTINCTCOUNT('Table'[recipe]) FilteredAmount=if([CountRecipe]>=2,SUM('Table'[amount])) 我无法解决的是在最后一个矩阵中显示配方(“过滤成分的总量”),以下是Excel中准备的所需输出: 我试图在一个新表中计算结果,但我也连接了
我只需要获得至少2份食谱中出现的食材数量,这部分我可以通过以下措施进行管理:
CountRecipe=DISTINCTCOUNT('Table'[recipe])
FilteredAmount=if([CountRecipe]>=2,SUM('Table'[amount]))
| recipe | ingredient | amount | count |
|--------|------------|--------|-------|
| R1 | I1 | 13 | 1 |
| R1 | I2 | 32 | 3 |
| R1 | I3 | 14 | 2 |
| R2 | I2 | 11 | 3 |
| R2 | I3 | 29 | 2 |
| R2 | I4 | 17 | 1 |
| R2 | I5 | 49 | 2 |
| R3 | I5 | 40 | 2 |
| R4 | I2 | 17 | 3 |
| R5 | I6 | 39 | 1 |
| R5 | I7 | 14 | 1 |
| R5 | I8 | 32 | 1 |
要遵守用户筛选器,请使用ALLSELECTED()
要遵守用户筛选器,请使用ALLSELECTED()
我将使用表中的列
count
。我刚刚在步骤add\u count\u col
中重新计算了以防万一
如果您相信自己的计算,则可以跳过此步骤
FilteredAmount =
VAR add_count_col =
ADDCOLUMNS (
'Table',
"col_count_recipe",
CALCULATE (
DISTINCTCOUNT ( 'Table'[recipe] ),
ALLSELECTED ( 'Table'[recipe] ),
FILTER ( ALL ( 'Table' ), [ingredient] = EARLIER ( 'Table'[ingredient] ) )
)
)
VAR ingredienttable =
FILTER ( add_count_col, [col_count_recipe] >= 2 )
VAR byingredient =
CALCULATE ( SUM ( 'Table'[amount] ), ingredienttable )
RETURN
byingredient
这是我的输出:
我将使用表中的列
count
。我刚刚在步骤add\u count\u col
中重新计算了以防万一
如果您相信自己的计算,则可以跳过此步骤
FilteredAmount =
VAR add_count_col =
ADDCOLUMNS (
'Table',
"col_count_recipe",
CALCULATE (
DISTINCTCOUNT ( 'Table'[recipe] ),
ALLSELECTED ( 'Table'[recipe] ),
FILTER ( ALL ( 'Table' ), [ingredient] = EARLIER ( 'Table'[ingredient] ) )
)
)
VAR ingredienttable =
FILTER ( add_count_col, [col_count_recipe] >= 2 )
VAR byingredient =
CALCULATE ( SUM ( 'Table'[amount] ), ingredienttable )
RETURN
byingredient
这是我的输出:
问题不是关于用户选择,我不知道你的答案有什么帮助。问题不是关于用户选择,我不知道你的答案有什么帮助。