Forum Discussion
LUCASM
Helper IV
3 years agoCALCULATE TABLE with Filter
I am tring to create a dynamic table from my source table based on a date slicer The date slicer [Period] looks like this "Week 38 2022" - pretty useless in itself I do also have another numeric co...
LUCASM
Helper IV
3 years agoHi vanessafvg
as this DAX is creating a table I cannot return ed
However I am using ed in a calculation which does work as expected
ASP_Last_Week =
var ed = selectedvalue ( TABLE1[YYYYWW] )
var ed_sales = CALCULATE (
sum ( TABLE1[Sales Values] ) ,
REMOVEFILTERS ( TABLE1[Period] ) ,
TABLE1[YYYYWW] = ed )
var ed_volume = CALCULATE(
sum ( TABLE1[Sales Units]) ,
REMOVEFILTERS ( TABLE1[Period]) ,
TABLE1[YYYYWW] = ed )
RETURN
DIVIDE( ed_sale, ed_volume )
If I return ed here I get the expected enddate - In this case 202238.
Since asking my question, one of my colleagues - whom I highly respect, has suggested that you cannot use SELECTEDVALUES in a CALCULATETABLE statement as CALCULATETABLE removes/ignores any filters that are in place.
I guess in my case, the Slicer is a filter.
Can anyone comment on this.
vanessafvg
Community Champion
3 years agosorry it was late and i missed that, he is 100% as you will not have row context which you need for selectedvalue.
- vanessafvg3 years ago
Community Champion
what if you created a variable using this?
var currdte = CALCULATE ( 'table'(date] ), ALLSELECTED( 'table'[date] ))