Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi Folks,
I'm new to DAX and am struggling with the following problem.
I have a table with years from 2011 until 2021.
I need to create a subset of that table with only the rows where the year is less or equal than a value chosen by the user.
Like this:
If I change the Chosen Year to 2017, I should have one more row in my Filtered Years table, if I change it to 2015, one row less.
I tried the CalculateTable function with a Filter clause based on a SelectedValue from a slicer, but as those tables are calculated at Refresh time, it didn't do what I needed.
Currently, the Chosen Year value is the result of the selection in a slicer, but I don't care how it's done, as long as it's selected by the user consuming my report.
Thanks
Solved! Go to Solution.
Hi,
You can create this kind of Filter measure and apply it to your visuals:
Note that my slicer date is from 'Visual Calendar' and there isn't relationship between that and 'Calendar'
Proud to be a Super User!
Thank you Valteri,
That does what I asked for but that wasn't the whole story.
From those 10 years, what I want is the user to select one and then keep the 5 years from that one down.
I have another table called Values with CompanyIDs and Years and for each a value.
What I want is show that in a matrix with the companies in the rows and the 5 years in the columns.
Basically the goal is to show up to 5 years of data, letting the user select the last of those years.
I was able to get what I wanted as far as the 5 years where concerned with the following calculated tables:
Get all the years before a chosen year:
Get the 5 years from the maximum of that table:
I added a relation between my Values table and the 5Exercices table and that filtered the data the way I wanted.
But it wasn't dynamically defined by the report user, so I was trying to build the "SomeExercice" table dynamically.
I implemented you solution like this:
where 'Exercice 4 Filter' is a duplicate of the Exercice table to have a table that is not connected with a relationship and it's the one I use in the slicer.
Now that my Excercice table is filtered, I made a relation between it and my Values table, but the years in that one are not filtered.
I'm a bit lost at this point.
Hi,
For the past 5 years dynamically you can modify the filter formula a bit:
Proud to be a Super User!
Thank you Valtteri,
That does indeed limit the filtered years to 5 but I can't filter my data based on those 5 years.
I still see all years even though the Exercice table is filtered and in a relationship with my data table.
I'm running out of time, so I'll just limit the number of years that I retrieve from my DB. Making that dynamic and in the hands of the user will have to wait.
Hi,
You can create this kind of Filter measure and apply it to your visuals:
Note that my slicer date is from 'Visual Calendar' and there isn't relationship between that and 'Calendar'
Proud to be a Super User!
User | Count |
---|---|
16 | |
15 | |
14 | |
12 | |
11 |
User | Count |
---|---|
19 | |
15 | |
14 | |
11 | |
10 |