Forum Discussion
jrhessey
6 years agoFrequent Visitor
Dax Filter Using slicer/Chiclet Value?
I'm trying to a plly a chiclet/slicer value to a dax filter fomula.
I found a post on here that I thought would work, but it's not returning the correct value
GetChicletValue = Var Select_Slicer = CALCULATE ( MIN ( DSO_All[CustGroup] ), ALLSELECTED( DSO_All ) )
Return Select_Slicer
The value that should be returned in the "First GetChicletValue" is OE, not AFT.
What I'm trying to do is pass that value on to another formula to get the previous row for a specific customer group (replace the "oe" with the slicer/chiclet value).
PreviousTotalOpen =
var PreviousDate = MAXX(FILTER(ALL(DSO_All),EARLIER(DSO_All[RunDate]) > DSO_All[RunDate] ),DSO_All[RunDate])
//return PreviousDate
Return CALCULATE(SUM(DSO_All[Calculated_OPENSALEDOLLAR]),FILTER(DSO_All,DSO_All[RunDate] = PreviousDate), DSO_All[CustGroup]="oe")
Am I on the right track or out in left field?
Thanks for any help, it's greatly appreciated!!
Make sure it is a measure, not calculated column. Besides, take a good look at https://www.sqlbi.com/articles/filter-arguments-in-calculate/.
3 Replies
- parry2kSuper User
- jrhesseyFrequent Visitor
How do I pass that value in to the following formula?
PreviousTotalOpen =var PreviousDate = MAXX(FILTER(ALL(DSO_All),EARLIER(DSO_All[RunDate]) > DSO_All[RunDate] ),DSO_All[RunDate])//return PreviousDateReturn CALCULATE(SUM(DSO_All[Calculated_OPENSALEDOLLAR]),FILTER(DSO_All,DSO_All[RunDate] = PreviousDate), DSO_All[CustGroup]="oe")I want to replace the "oe" with the selected value. I triedDSO_All[CustGroup]=GetChicletValuebut I get the error that "a calculate function has been used in a true/false expression that is used as a table filter expression. this is not allowed."So I tried setting a variableVar Select_Slicer = SELECTEDVALUE( DSO_All[CustGroup] )and using this codeDSO_All[CustGroup]=Select_SlicerI don't recieve any errors, but the column goes blank.Here is the end goal, whatever values I select i nthe CustGroup and ForecastCode chiclet/slicers should be inserted into the appropriate section of the formula where "custgroup" or "forecastcode".So I could have selected OE and AFT for custgroup and A and B for forecastcode for example. All those rows should be returned for the top table to sum, etc.Hopefully this makes it a little more clear. Thanks for your help parry2k!!- v-chuncz-msftCommunity Support
Make sure it is a measure, not calculated column. Besides, take a good look at https://www.sqlbi.com/articles/filter-arguments-in-calculate/.