Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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.
MonthName | MonthValue |
Current | 3 |
Jan | 1 |
Feb | 2 |
Mar | 3 |
Apr | 4 |
I have another table Data that contains the data that I am using:
ID | Month | Value |
A | 1 | 22 |
A | 2 | 355 |
A | 3 | 76 |
A | 4 | 54 |
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:
ID | Value |
A | 22 |
A | 355 |
A | 76 |
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
Solved! Go to Solution.
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 , 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
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
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.
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
Thank you for your help! That was what was missing! It works now 🙂
Hi @Anonymous ,
Glad to know that your issue is solved,could you pls mark the reply as answered to close it?
Much appreciated.
User | Count |
---|---|
98 | |
90 | |
82 | |
73 | |
67 |
User | Count |
---|---|
115 | |
102 | |
98 | |
71 | |
67 |