Forum Discussion
How to use userselected Measure inside Filter() function
Hi Dear Comunity,
I have simple data set that has task name , Start date and end date.
I have to create a gannt chart like below but the requirement is that user should click the on bar and he should get all the tasks starting 30 days before the selected task , and 30 days after the selected task.
Now my solution,
I have created two measures start and end date based on task selection like this,
5 Replies
- lbendlinSuper User
Using SELECTEDVALUE inside CALCULATE is asking for trouble if you use the same table or related tables.. Are you familiar with the concepts of row context and filter context, and with disconnected tables?
A safer way would be to use variables, like so:
Selected_Task_End_Date = var t = SELECTEDVALUE(Sheet1[Task]) return CALCULATE( min( Sheet1[end date] ), Sheet1[Task]= t )+30 - mob99pkNew Member
hi Dear ibendlin,
Many Many thanks for replying ,
I did apply the solution as you mentioned,
Selected_Task_End_Date
but this is still not filtering
Any
Ganntt_table = CALCULATETABLE(Sheet1, filter(sheet1, Sheet1[start date] >= Sheet1[Selected_Task_Start_Date] )
Any guidance to fix that ?
- lbendlinSuper User
You need to use the same approach again. Move the measure out of the filter condition into a variable before the CALCULATE.
- v-angzheng-msftCommunity Support
Hi, mob99pk
May I ask if your problem has been solved? Is the above post helpful to you?
If it does, could you please mark the post which help as Answered? It will help the others in the community find the solution easily if they face the same problem with you. Thank you
It makes it easier to give you a solution.
- Sample (dummy dataset) data as text, use the table tool in the editing bar
- Expected output from sample data
- Explanation in words of how to get from 1. to 2.
Best Regards,
Community Support Team _ Zeon ZhengIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- mob99pkNew Member
hi ,
Team .
Thanks alot for your support but this didnt support, i still cant filter it like this.