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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Diabetic
New Member

Chart Granularity

I have a graph that shows the Offered, Answered & Abandoned calls from my data set. I have this on the y-axis of a bar chart and then I have created a parameter for the dates on the x-axis. This allows me to use a slicer to swap between the granularity levels (Daily, Weekly, Monthly).To achieve this, I have a date table that has all the dates for this year, along with a column defining the month and a column defining the week commencing date.

 

I want the Daily view to show the last 30 days, the weekly view to show the last 8 weeks and the monthly view to show the last 12 months. This is where I am running into an issue. I can't get the dates to change with the granularity which causes my data to show an entire year of data on all the views.

 

How can I change this so the date range of the displayed data aligns with the desired granularity that is being set by the slicer?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can try creating a measure which you would use in the filter pane, set to only show when the value is 1.

Filter Measure =
VAR FirstVisibleDate =
    MIN ( 'Date'[Date] )
VAR LastVisibleDate =
    MAX ( 'Date'[Date] )
VAR LastDateToShow =
    TODAY ()
VAR __SelectedGranularity =
    SELECTCOLUMNS (
        SUMMARIZE ( Parameter, Parameter[Parameter], Parameter[Parameter Fields] ),
        Parameter[Parameter]
    )
VAR FirstDateToShow =
    IF (
        COUNTROWS ( __SelectedGranularity ) = 1,
        SWITCH (
            __SelectedValue,
            "Daily", LastDateToShow - 30,
            "Monthly", EOMONTH ( LastDateToShow, -13 ) + 1,
            "Weekly",
                LOOKUPVALUE ( 'Date'[Week commencing], 'Date'[Date], LastDateToShow - 7 * 8 )
        )
    )
VAR Result =
    IF (
        FirstVisibleDate >= FirstDateToShow
            && LastVisibleDate <= LastDateToShow,
        1
    )
RETURN
    Result

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

You can try creating a measure which you would use in the filter pane, set to only show when the value is 1.

Filter Measure =
VAR FirstVisibleDate =
    MIN ( 'Date'[Date] )
VAR LastVisibleDate =
    MAX ( 'Date'[Date] )
VAR LastDateToShow =
    TODAY ()
VAR __SelectedGranularity =
    SELECTCOLUMNS (
        SUMMARIZE ( Parameter, Parameter[Parameter], Parameter[Parameter Fields] ),
        Parameter[Parameter]
    )
VAR FirstDateToShow =
    IF (
        COUNTROWS ( __SelectedGranularity ) = 1,
        SWITCH (
            __SelectedValue,
            "Daily", LastDateToShow - 30,
            "Monthly", EOMONTH ( LastDateToShow, -13 ) + 1,
            "Weekly",
                LOOKUPVALUE ( 'Date'[Week commencing], 'Date'[Date], LastDateToShow - 7 * 8 )
        )
    )
VAR Result =
    IF (
        FirstVisibleDate >= FirstDateToShow
            && LastVisibleDate <= LastDateToShow,
        1
    )
RETURN
    Result

Excellent, that worked brilliantly. Thank you

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.