Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
mob99pk
New Member

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. 

mob99pk_1-1647609264983.png

 

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.

 

mob99pk_3-1647609406403.png

mob99pk_4-1647609486312.png

 

 

Now my solution,

I have created two measures  start and end date based on task selection like this,

 

Selected_Task_End_Date =
(CALCULATE(
min( Sheet1[end date] ),
FILTER(Sheet1,Sheet1[Task]= SELECTEDVALUE(Sheet1[Task]))
))+30
 
Selected_Task_Start_Date =
(CALCULATE(
min( Sheet1[start date] ),
FILTER(Sheet1,Sheet1[Task]= SELECTEDVALUE(Sheet1[Task]))
))-30
 
 and then i am creating another table which should filter the value on the fly and make a filtered table where start date is greater than Selected task start date and less than selected task end date.
 
Ganntt_table = CALCULATETABLE(Sheet1, filter(sheet1, Sheet1[start date] >= Sheet1[Selected_Task_Start_Date] )
 
But this doesnot filter any thing,
on the other hand , if i give a staitic input to filter it works,
Ganntt_table = CALCULATETABLE(Sheet1, filter(sheet1, Sheet1[start date] >= Today() )
 
 
Can some one help me how to use this user selected measure inside the filter funciton 
 
 
Many thanks

 

5 REPLIES 5
v-angzheng-msft
Community Support
Community 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.

  1. Sample (dummy dataset) data as text, use the table tool in the editing bar
  2. Expected output from sample data
  3. Explanation in words of how to get from 1. to 2.

 

Best Regards,
Community Support Team _ Zeon Zheng

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hi ,

Team .

 

Thanks alot for your support but this didnt support, i still cant filter it like this.

mob99pk
New 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(Sheet1filter(sheet1Sheet1[start date] >= Sheet1[Selected_Task_Start_Date] )

 

Any guidance to fix that ?

You need to use the same approach again. Move the measure out of the filter condition into a variable before the CALCULATE.

lbendlin
Super User
Super 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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors