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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
asadnsit
New Member

Issue in using "selectedvalue" function for filtering another table

I am facing issue in using value selected in a date slicer to filter another table:

 

Table1: Employee master 

 

asadnsit_0-1735808521850.png

 

Table2: Calculated date table created using calendar function

 

asadnsit_1-1735808550784.png

 

Now I have put a slicer in my dashboard using Table2 (Only single value selection allowed)

asadnsit_5-1735808872996.png

 

Selected value is appearing fine in display card using "selectedvalue" function

 

DAX query for measure :

 

Selected_date = DATEVALUE(SELECTEDVALUE(Date_Table[Date]))

 

asadnsit_6-1735808906042.png

 

Now I am creating calculated table by filtering Table 1 using value selected in slicer:

 

DAX code:

Emp_master_filtered =
CALCULATETABLE
Emp_Master,
Emp_Master[DOJ]<=DATEVALUE(SELECTEDVALUE(Date_Table[Date])),
Emp_Master[DOR] >= DATEVALUE(SELECTEDVALUE(Date_Table[Date]))
)

 

asadnsit_7-1735808956403.png

 

But output is always blank. Please help

 

 

 

 

1 ACCEPTED SOLUTION
v-huijiey-msft
Community Support
Community Support

Hi @asadnsit ,

 

Thanks for the reply from bhanu_gautam .

 

As I understand it, you want to filter Emp_Master to present data based on the selected date in the slicer on Date_Table, right?

 

The values obtained using the slicer object in the report view cannot affect the calculated columns, calculated tables created in the data view. As a workaround, you can use measure to filter data dynamically instead of creating calculated tables.

 

Create a measure:

Emp_master_filtered = 
CALCULATE(
    COUNTROWS(Emp_Master),
    FILTER(
        Emp_Master,
        Emp_Master[DOJ] <= [Selected_date] &&
        Emp_Master[DOR] >= [Selected_date]
    )
)

 

Add Emp_master_filtered to the filter pane and set the filter rule with Emp_master_filtered = 1.

 

Filter the date in Slicer and the final page result is shown below:

vhuijieymsft_0-1735871413413.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

3 REPLIES 3
v-huijiey-msft
Community Support
Community Support

Hi @asadnsit ,

 

Thanks for the reply from bhanu_gautam .

 

As I understand it, you want to filter Emp_Master to present data based on the selected date in the slicer on Date_Table, right?

 

The values obtained using the slicer object in the report view cannot affect the calculated columns, calculated tables created in the data view. As a workaround, you can use measure to filter data dynamically instead of creating calculated tables.

 

Create a measure:

Emp_master_filtered = 
CALCULATE(
    COUNTROWS(Emp_Master),
    FILTER(
        Emp_Master,
        Emp_Master[DOJ] <= [Selected_date] &&
        Emp_Master[DOR] >= [Selected_date]
    )
)

 

Add Emp_master_filtered to the filter pane and set the filter rule with Emp_master_filtered = 1.

 

Filter the date in Slicer and the final page result is shown below:

vhuijieymsft_0-1735871413413.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Thanks alot for the solution --> Using Measure as a filter resolved my issue.

bhanu_gautam
Super User
Super User

@asadnsit The issue you're facing is likely due to the context in which the SELECTEDVALUE function is being evaluated. When you use SELECTEDVALUE inside a calculated table, it might not be able to correctly capture the slicer context. 

 

Create a measure to capture the selected date:

Selected_date = MAX(Date_Table[Date])

 

Use this measure in your calculated table to filter Emp_Master:

Emp_master_filtered =
VAR SelectedDate = [Selected_date]
RETURN
FILTER(
Emp_Master,
Emp_Master[DOJ] <= SelectedDate &&
Emp_Master[DOR] >= SelectedDate
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.