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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Dynamic x-axis min/max range

Hello,

 

I have a time-series graph and my goal is to have the x-axis min and max dates adjust automatically based on the slicer selected value's start and end dates.

 

1. Sample data/scenario:

Say I have 3 different tables: 1) 'Student GPA' which has information for 4 different Student_IDs and how the GPA changes over time for each one; 2) 'Number of Exams Taken' which shows the number of exams taken for the same Student_IDs; 3) 'Dates to Use' which shows x_min and x_max dates for each Student_ID and these are the dates that I want to use on the x-axis. If you notice, the Date and Student_ID columns are exactly the same and in the same order in all three tables. In 'Dates to Use' table, each Student_ID has a unique x_min and x_max combination, they are just listed multiple times because the same Student_ID appears multiple times in the table.

 

1) Student GPA table

DateStudent_IDGPA
1/5/201500013.1
2/1/201500023.2
3/3/201500032.9
4/1/201500043.1
5/1/201500013.2
8/1/201500033.8
12/1/201500043.5
1/3/201600013.5
5/4/201600023.6
6/30/201600023.9
9/12/201600033.9
5/30/201600043.6
1/5/201700033.9
2/2/201700043.8

 

2) Number of Exams Taken table

DateStudent_IDNum_Exams
1/5/201500012
2/1/201500021
3/3/201500033
4/1/201500041
5/1/201500013
8/1/201500034
12/1/201500046
1/3/201600015
5/4/201600024
6/30/201600025
9/12/201600036
5/30/201600049
1/5/201700038
2/2/2017000410

 

3) Dates to Use table

DateStudent_IDx_minx_max
1/5/201500012/1/2015 
2/1/201500023/2/20157/3/2016
3/3/201500034/3/2015 
4/1/201500046/3/20152/3/2017
5/1/201500012/1/2015 
8/1/201500034/3/2015 
12/1/201500046/3/20152/3/2017
1/3/201600012/1/2015 
5/4/201600023/2/20157/3/2016
6/30/201600023/2/20157/3/2016
9/12/201600034/3/2015 
5/30/201600046/3/20152/3/2017
1/5/201700034/3/2015 
2/2/201700046/3/20152/3/2017

 

2. How the tables are linked:

There are two separate dimension tables: Student_ID and Date, both were created using the Student_ID and Date columns from 'Student GPA' and 'Number of Exams Taken' tables, respectively. So the 'Student GPA' and 'Number of Exams Taken' tables are connected through both of these dimension tables.

 

3. What I want my report to show:

The report should display 'GPA' and 'Num_Exams' over time for each unique Student_ID over time. I also have a slicer where one can selected Student_ID and the graph updates accordingly. The x-axis is currently using the date dimension table date.

What I want my report to do is the following:

Once the user selects a specific Student_ID from the slicer, the x-axis should automatically adjust the x-axis range to use the x_min and x_max columns from the 'Dates to Use' table. So for example, currently the x-axis is using min value of 1/5/2015 and max value of 2/2/2017. If I select Student_ID 0002, then the x-axis range should automatically update to use 3/2/2015 as x_min and 7/3/2016 as x_max. This should be done by looking up by matching on the Student_ID column and picking the earliest of the x_min/x_max dates given that they are repeated multiple times. If there is no x_max date (for example, for 0001), then it should use the original date that was in the date dimension table.

 

Thanks in advance.

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

You may create a measure to filter the dates for x-axis. For example:

 

IF(SELECTEDVALUE(axis_dates)>=MIN(slicer_dates)&&SELECTEDVALUE(axis_dates)<=MAX(slicer_dates),1,0)

Then put this measure to visual level filter that filter measure = 1.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

6 REPLIES 6
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

You may create a measure to filter the dates for x-axis. For example:

 

IF(SELECTEDVALUE(axis_dates)>=MIN(slicer_dates)&&SELECTEDVALUE(axis_dates)<=MAX(slicer_dates),1,0)

Then put this measure to visual level filter that filter measure = 1.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Anonymous
Not applicable

@v-jayw-msft Thank you.

lbendlin
Super User
Super User

that's controlled by which values you add to the visual. If you include values from both fact tables then the entire covering range will be used.

Anonymous
Not applicable

Thanks for clarifying. 

Anonymous
Not applicable

@lbendlin Thank you for your suggestion. 

Something that I forgot to mention in my question was that the date range for one of the tables could be smaller/larger than the second table. Basically, what I'm looking to do is that I'm plotting two variables/columns (in this case, it's GPA and Num_Exams), each coming from a different table, and I only have one date column that is coming from the date dimension table. How can I limit the x-axis to the range that is available only in one of those series (i.e. one of the columns in one of those two tables)?

 

Thanks.

lbendlin
Super User
Super User

You might be overcomplicating things.  Use the date from the calendar table as the x axis of the visual. Feed the slicer from the Student dimension table. Now when you  select a student it will automatically restrict the date range on the chart to the available data.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.