Forum Discussion
How Slicer Filter can affect column calculations?
Hello everyone,
I'm a new user of Power BI and need your help to solve the problem.
I have a data of customer who have unique identifier and corresponding date field.
I want to create a column of min and max date values. e.g. in this case min (date) would be 1/15/2021 and max(date) 12/1/2021. Just I want these columns of max and min values to be changed depending on slicer filter. Namely, when I mark on slicer dates from 2/23/2021 to 10/25/2021 then column for maximum date should be 8/20/2021 and column for minimum date should be 3/19/2021 for the table above.
I've tried to write function like this but did not work.
maxDateAll= CALCULATE ( MAX ( tbl[date] ), ALLSELECTED(tbl))How can slicer filter affect not just visualization but also column/table calculations?
Could you please help me to solve this issue?
Thank you in advance
Nini1 , Ideally these should work from Max and min
maxx(allselected(tbl) , tbl[date])
minx(allselected(tbl) , tbl[date])
But if slicer is on another table try like
maxDateAll=
Var _max = maxx(allselected(Date) , Date[date])
Var _min = minx(allselected(Date) , Date[date])
return
CALCULATE ( MAX ( tbl[date] ), filter(ALLSELECTED(tbl), tbl[date] <= _max && tbl[date] >= _min))
6 Replies
- AnonymousNot applicable
Hi Nini1 ,
No, it's not possible. Since calculated column is static, it could not be dynamically changed based on the selection in slicer.
For your case, please use the same syntax to create measure instead:
max = CALCULATE(MAX('Table'[date]), ALLSELECTED('Table'))Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Thank you, this solved my problem as well that no one on community could answer!
- Nini1Frequent Visitor
Thank you very much!
- AnonymousNot applicable
- amitchandak
Super User
Nini1 , Ideally these should work from Max and min
maxx(allselected(tbl) , tbl[date])
minx(allselected(tbl) , tbl[date])
But if slicer is on another table try like
maxDateAll=
Var _max = maxx(allselected(Date) , Date[date])
Var _min = minx(allselected(Date) , Date[date])
return
CALCULATE ( MAX ( tbl[date] ), filter(ALLSELECTED(tbl), tbl[date] <= _max && tbl[date] >= _min))- Nini1Frequent Visitor
Thank you very much!