Forum Discussion
Change calculated table dynamically on slicer selection
- 6 years ago
Hi Ani26 ,
Calculated tables cannot be affect dinamically by slicers, so you cannot have a dinamic calculted table on the fly to use on a visualization, however you can create a measure that makes use of a calculated table (as a variable) and then make it dinamic with the use of slicers.
I was looking at your example and didn't understood what you want to create is the Bracket part or only the filtering of the data by bit?
- 6 years ago
Hi Ani26 ,
As MFelix said, it can't create a calculated table dynamically based on slicers. But you can do it in measures. Here is my sample that you could have a try.
Month-Year = DISTINCT('Date'[Month-Year])Bracket = VAR X = CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Date', 'Date'[Month-Year] = [S] ) ) RETURN SWITCH ( TRUE (), X > 0 && X < 1, "0-1", X >= 1 && X < 2, "1-2", x > 2, ">2", BLANK () )BIT = VAR BIT = SEARCH ( "BIT", MAX ( 'Table'[Attribute] ),, 1000 ) RETURN CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Date', 'Date'[Month-Year] = [S] && BIT <> 1000 ) )
Hi Ani26 ,
As MFelix said, it can't create a calculated table dynamically based on slicers. But you can do it in measures. Here is my sample that you could have a try.
Month-Year = DISTINCT('Date'[Month-Year])Bracket =
VAR X =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Date', 'Date'[Month-Year] = [S] )
)
RETURN
SWITCH (
TRUE (),
X > 0
&& X < 1, "0-1",
X >= 1
&& X < 2, "1-2",
x > 2, ">2",
BLANK ()
)
BIT =
VAR BIT =
SEARCH ( "BIT", MAX ( 'Table'[Attribute] ),, 1000 )
RETURN
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Date', 'Date'[Month-Year] = [S] && BIT <> 1000 )
)
What if you want to reference this table multiple times for downstream measures and or build other columns from the table rows? Surely it isn't efficient to define this table in every measure you want to create. Is there not another way to do this in PowerBi?
- MFelix1 year agoSuper User
Hi tmarcus,
Depends on the end result you may used calculation groups or other options to make this work, however the problem that you describe also is the same for calculated tables that that would be usong those slicer options. Currently you also have visual calculations that can be added to that a specific visual.
Context is very important.