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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
wpf_
Post Prodigy
Post Prodigy

How to use dateadd() with the selectedvalue from a date slicer without errors

I have matrix_2 where I want to take the date value from a slicer which filters matrix_1, and shows the values that is offset by -7 days.  So if showing values for Monday on matrix_1, I want matrix_2 to show values for the previous Monday.  

 

I am using dateadd(selectedvalue(table[transaction_date]), -7, day) but i am getting error: 

 

a function 'selectedvalue' has been used in a true/false expression that is used as a table filter expression. This is not allowed.  Hope someone can help. Thanks. 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

Is Transaction Date the one in the slicer? DateAdd will accept the whole column, so you shouldn't need to use the SelectedValue function at all, but depends what else is going on with your relationships between matrix 2 data and transaction date.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Ensure that you have a Calendar Table and the slicer has the Date column from this Calendar table.  This measure should work

=min(calendar[date])-7

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AllisonKennedy
Super User
Super User

Is Transaction Date the one in the slicer? DateAdd will accept the whole column, so you shouldn't need to use the SelectedValue function at all, but depends what else is going on with your relationships between matrix 2 data and transaction date.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy 

 

Wow didn't know you can do that without the selectedvalue function. It worked, unfortunately it didn't help me with what I wanted to do. But thanks, it will help me down the road.  

@wpf_ Glad you learned something new at least. Post a new question with some sample data and desired output and we can keep helping you get the final result you need.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors