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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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