如题,要建立一个动态切换维度的图表,我采取的步骤如下:
- 用公式建立一个新的表格,把要用的维度从Products数据表中提取出来:
SelectedDimensions = UNION( DISTINCT(SELECTCOLUMNS(Products; "Value"; Products[Category]; "Dimension"; "Category")); DISTINCT(SELECTCOLUMNS(Products; "Value"; Products[Brand]; "Dimension"; "Brand")); DISTINCT(SELECTCOLUMNS(Products; "Value"; Products[Subbrand]; "Dimension"; "Subbrand")) )
结果如下:
- 建立一个可根据维度切换的度量值:
Avg discount dynamic = SWITCH( TRUE(); SELECTEDVALUE(SelectedDimensions[Dimension]) = "Category"; CALCULATE([Avg basic discount in money];TREATAS(VALUES(SelectedDimensions[Value]);Products[Category])); SELECTEDVALUE(SelectedDimensions[Dimension]) = "Brand"; CALCULATE([Avg basic discount in money];TREATAS(VALUES(SelectedDimensions[Value]);Products[Brand])); SELECTEDVALUE(SelectedDimensions[Dimension]) = "Subbrand"; CALCULATE([Avg basic discount in money];TREATAS(VALUES(SelectedDimensions[Value]);Products[Subbrand])) )
动态切换维度的图表:
但是,当我选择了维度”Category",同时在切片器中筛选“"Category"的时候,图表给出的是所有值:
当我选择了维度”Category",但是选择其他切片器的时候,图表显示的正确筛选的值:
哪位大神可以指点一下,如何让切片器和维度同时筛选”Category"时,图片可以给出筛选的值呢?