Forum Discussion
Help Needed with Time Axis Filtering in Power BI
- 1 year ago
Hi Uhrond
You'll need to use a disconnected table for the slicer and create another measure that references a column from that disconnected table. If you use a column from a related table, it will only return the rows that have been selected.Please see the attached sample pbix
Hi Uhrond, the reason of your problem is a use of SELECTEDVALUE() function. As you can find in its definition, it expects only 1 value in a specified column: "Returns the value when thereโs only one value in the specified column, otherwise returns the alternate result." - SELECTEDVALUE โ DAX Guide
Let's break down your case in 2 parts:
- You have a slicer and a bar chart that interact between themselves. In such situation, if you select a single date is a slicer, you should get the desired result, because SELECTEDVALUE('Table'[Date]) will return a single value from where you can retrieve the year. However, if you select multiple days or remove any filtering from slicer what is a single value of column [Date]? Correct, there is no one. Therefore, Power BI evaluates alternate result, which is not specified in your case, therefore it's blank(). And the Year( Blank() ) = Blank()
- interaction between slicer and visual is turned off: in such situation you get the same problem described above, because all dates from Table are selected for bar chart.
To resovle the problem, you can replace SELECTEDVALUE() with MAX() or MIN(). This will assure that even when multiple dates are selected, only one of them is considered when calculating a year.
Good luck with your project! ๐
Thank you for your response. Unfortunately, even with MAX(), it does not work as I would like (I think it takes the MAX() of each date and therefore each year.) :