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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Filter data using selected value in slicer

Hello everyone!

I have been trying to do something that seems simple but I cannot achieve it.

I have a table that I use for a slicer and it allows the user to choose the month. The column MonthName is in the slicer.

 

MonthNameMonthValue

Current

3

Jan

1

Feb

2
Mar3
Apr4

 

I have another table Data that contains the data that I am using:

IDMonthValue
A122
A2355
A376
A454

 

What I want is to show values of Data when the Month of the Value is less or equal to the Month that the user chose in the slicer (I need the table Months separate because I have a 'Current month' selection possibility'). Here is the measure that I created:

Measure = 
VAR monthSelected = SELECTEDVALUE(MonthSlicer[MonthValue])
RETURN
CALCULATE(SUMX(Data,[Value]), Data[Month]<=monthSelected)

The expected output is if the User chooses the Month 3:

IDValue
A22
A355
A76

 

What I get with this measure is only the line that has Month=3 and not the lines that have Month=1 and Month=2.

 

I guess it has something to do with the context of the filters on the visual.

In the previous case, the slicer is filtering the visual table that show the output.
When I remove this filtering, the measure works only if I put a fixed number (e.g. 3) instead of SELECTEDVALUE.

Thank you for




1 ACCEPTED SOLUTION

You can create a new measure for Value that removes the month filter and then reapplies based on how you want, so

VALUE = CALCULATE(SUM(table[value]), ALL(Month), DataMonth< Selected Month)

Pardon my terrible syntax, that's just meant to provide theory. Let me know if it doesn't make sense.

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

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , I am hoping both tables are joined. It is a number use less than equal to option in the slicer.  With small down arrow in slicer you have that option

AllisonKennedy
Super User
Super User

Is there any relationship between your Month table and Data table? If there is, it will only ever show the month that is selected, so you'll need to remove the relationship or create a series of measures that remove the filter.


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

Anonymous
Not applicable

Thank you for your reply!

There is indeed a relationship between Data[Month] and Slicer[MonthValue]. However I need it for other visuals as well as in order to have the right values for each ID.

You can create a new measure for Value that removes the month filter and then reapplies based on how you want, so

VALUE = CALCULATE(SUM(table[value]), ALL(Month), DataMonth< Selected Month)

Pardon my terrible syntax, that's just meant to provide theory. Let me know if it doesn't make sense.

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

Anonymous
Not applicable

Thank you for your help! That was what was missing! It works now 🙂

Anonymous
Not applicable

Hi @Anonymous ,

 

Glad to know that your issue is solved,could you pls mark the reply as answered to close it?

 

Much appreciated.

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.