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
Everton
Helper I
Helper I

Change X Axis Start and End Depending Upon Data In Graph

Hi,

 

I have a graph which displays appointments booked by time:

4.PNG

The X Axis is at 15 minute intervals. This is my data model, the table v_15MinuteIntervals is a dimension table with a row for every 15 minutes in a day:5.PNGI have my graph axis defined like this:

6.PNG

What I want to do is have my X axis start and end at the time when appointments start and end, so rather than going for a 24 hour period it would start around 6 AM and end around 2:15 PM. In the X-Axis properties I can see we can define Start and End properties. I can't seem to set these as a value from my data set though. I can only select a date, but I need these to be dynamic. 

9.PNG

Is there anyway to set the Start and End properties on the X-Axis to be a value from my data set?

1 ACCEPTED SOLUTION

Ahh I see,

There are many ways you could do this. Here is one that should work.

Note ALLSELECTED could be changed to ALL to give absolute min/max times with data:

 

Appointment Count =
VAR MinTimeWithData = 
    CALCULATE ( MIN ( v_Apointments[Appointment Time] ), ALLSELECTED () )
VAR MaxTimeWithData =
    CALCULATE ( MAX ( v_Apointments[Appointment Time] ), ALLSELECTED () )
VAR MinTimeFiltered =
    MIN ( v_15MinuteIntervals[15MinInterval] )
VAR MaxTimeFiltered =
    MAX ( v_15MinuteIntervals[15MinInterval] )
RETURN
    COUNT ( v_Appointments[Appointment] )
    + IF (
        MinTimeFiltered <= MaxTimeWithData && MaxTimeFiltered >= MinTimeWithData,
        0
    )

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

4 REPLIES 4
Everton
Helper I
Helper I

Update:

 

I have created two measures, one with the first time of the appointments, one with the last time of the appointments. Is there a way I can make the X-Axis stay within these parameters?

 

Appointments Start At = Min(v_Appointments[Appointment Time])

Appointments End At = MAX(v_Appointments[Appointment Time])

@Everton 

Normally the x-axis will adjust automatically to exclude ranges

  1. Below the minimum value where any measure is nonblank
  2. Above the maximum value where any measure is nonblank.

 

It looks like your Appointment Count measure is returning zero instead of BLANK over certain ranges. Ideally, you should define Appointment Count so that it returns BLANK rather than zero. Is this possible in your situation?

 

Normally this happens automatically with measures using COUNTROWS or DISTINCTCOUNT, but your measure may be more complex. You can always write the measure to replace zero with BLANK, or you could incorporate the bounds you described above into the measure definition.

 

Could you post the definition of Appointment Count?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Hi Owen,

 

Yes, you are right, I have made it return 0 rather than blank:

 

Appointment Count = Count(v_Appointments[Appointment]) + 0

 

I needed the graph to dip down to 0 rather than blank when there is no appointments. I guess the ideal situation is if I can return blank if the time is before or after the first and last appointment times.

Ahh I see,

There are many ways you could do this. Here is one that should work.

Note ALLSELECTED could be changed to ALL to give absolute min/max times with data:

 

Appointment Count =
VAR MinTimeWithData = 
    CALCULATE ( MIN ( v_Apointments[Appointment Time] ), ALLSELECTED () )
VAR MaxTimeWithData =
    CALCULATE ( MAX ( v_Apointments[Appointment Time] ), ALLSELECTED () )
VAR MinTimeFiltered =
    MIN ( v_15MinuteIntervals[15MinInterval] )
VAR MaxTimeFiltered =
    MAX ( v_15MinuteIntervals[15MinInterval] )
RETURN
    COUNT ( v_Appointments[Appointment] )
    + IF (
        MinTimeFiltered <= MaxTimeWithData && MaxTimeFiltered >= MinTimeWithData,
        0
    )

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

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.