Forum Discussion
Line chart with Legend and additional measure
- 4 years ago
RafalMonka Don't you have another filter directly filter the table1, if those are then the solution provided by AlexisOlson should work, let's say you have a table1 filter on a project and only two users are associated with that project, in the solution, it will show only two users, not other users. Seems like you need to tweak your data model if this is not working as expected but the solution provided AlexisOlson is the way to go.
✨ Follow us on LinkedIn and subscribe to our YouTube channel
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Hi,
we have worked on Alexis's example, by adding visual filter Table1[User] and column Table1[Project].
When filtering by Project everything works very well.
However, when you try to select users on visual filter Table1[User], the changes are not reflected on Legend[User].
As you can see - user "Zbi" is deselected in visual filter but it still appears in Legend.
Modification of model is not possible.
Is it possible to modify code in order to include in chart Legend only items selected on visual filter Table1[User]?
- AlexisOlson4 years ago
Super User
Try using KEEPFILTERS.
ChartValue = IF ( SELECTEDVALUE ( Legend[User] ) = "Average", AVERAGEX ( VALUES ( Table1[User] ), CALCULATE ( SUM ( Table1[Value] ) ) ), CALCULATE ( SUM ( Table1[Value] ), KEEPFILTERS ( TREATAS ( VALUES ( Legend[User] ), Table1[User] ) ) ) )