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 )
)
- Ani266 years agoHelper III
Thank you v-xuding-msft and MFelix . Your solutions made it work. 🙂
- DVA4963 years agoFrequent Visitor
Hello,
Im trying to do something similar by using the date selected as a cutoff date but get the values in the new column same as the original vlaues with the corresponding date if the date is before the cutoff one and zero if the date is after cutoff date. I create an additional column called B&S. When I select 31.12.2024 for example I get the values from 2023 but not the ones from 2019, 2020... Can you help me?
B&S =VAR X =SEARCH ("öGIG", MAX('öGIG'[Asset]),,1000)RETURNCALCULATE(SUM('öGIG'[CF]),FILTER(Dates, Dates[Dates] < [S] && X <>1000)) - tmarcus1 year agoNew Member
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.