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

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

Reply
gumis_rulez
Helper I
Helper I

Granularity with dynamic range limitation

On the left side I have slicer for granularity - made with additional table connected with relationship in both directions.

On the right side I have slicer which limits the range of data.

 

How to combine those two solutions so that they would work?

mm01.JPG

 

 

https://drive.google.com/file/d/1XwIhdvOdNRbNfQNx9ws-EzrTXT_OkNy2/view?usp=sharing 

2 REPLIES 2
DataInsights
Super User
Super User

@gumis_rulez,

 

One approach is to use a field parameter for the D/W/M/Q/Y slicer. Use the field parameter in the x-axis to enable dynamic selection of granularity.

 

https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




The granularity works: D/W/M/Q/Y is a slicer based on the table:

 

hlp_Dynamic Date Selections = 
UNION(
    ADDCOLUMNS(
        CALENDAR(
            MIN(dimCalendar[Date]),
            MAX(dimCalendar[Date])
        ),
        "Visual Date", [Date],
        "Type", "D",
        "Order", 1
    ),
    ADDCOLUMNS(
        CALENDAR(
            MIN(dimCalendar[Date]),
            MAX(dimCalendar[Date])
        ),
        "Visual Date", 
        [Date] - WEEKDAY([Date], 2) + 1,
        "Type", "W",
        "Order", 2
    ),
    ADDCOLUMNS(
        CALENDAR(
            MIN(dimCalendar[Date]),
            MAX(dimCalendar[Date])
        ),
        "Visual Date", YEAR([Date]) & "-" & MONTH([Date]),
        "Type", "M",
        "Order", 3
    ),
    ADDCOLUMNS(
        CALENDAR(
            MIN(dimCalendar[Date]),
            MAX(dimCalendar[Date])
        ),
        "Visual Date", YEAR([Date]) & "-Q" & CEILING(MONTH([Date])/3, 1),
        "Type", "Q",
        "Order", 4
    ),
    ADDCOLUMNS(
        CALENDAR(
            MIN(dimCalendar[Date]),
            MAX(dimCalendar[Date])
        ),
        "Visual Date", YEAR([Date]),
        "Type", "Y",
        "Order", 5
    )
)

 

Question is how to combine:

 

Date Param = 
CALCULATE(
    [Sales],
    KEEPFILTERS(
        DATESBETWEEN(
            dimCalendar[Date],
            [Selected Min Date],
            [Max Date]
        )
    )
)

 

where

 

Selected Min Date = 
VAR _MaxDate = [Max Date]
VAR _MinDate = [Min Date] - 1

RETURN

SWITCH(
    'hlp_Date Selection'[Selected Date Selection],
    "1W", _MaxDate - 7,
    "1M", EDATE(_MaxDate, -1),
    "3M", EDATE(_MaxDate, -3),
    "TY", DATE(YEAR(_MaxDate), 1, 1),
    "1Y", EDATE(_MaxDate, -12),
    "ALL", _MinDate )

and

Max Date = 
CALCULATE(
    MAX(dimCalendar[Date]),
    REMOVEFILTERS(dimCalendar[Date])
)

to automatically limit the range. If I choose 3M to limit the displayed data to three months?

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.