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
steph_io
Advocate II
Advocate II

How to use a numeric parameter to filter a date range

I have a CAGR calculation that uses parameters of Number of months to base the rate calculation, and Number of future months to plot the forecasted revenue.  How do I use these paraments to filter the page and/or visual to only show the X number of past months and X number of future months in the chart?

I do have a date table, but the parameter table does not link to it. The filter of the visual does not accept a measure (measure is used to capture the value entered in the parameter).  Any ideas?

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

Hi @steph_io,

 

For your scenario, you can refer to below steps to filter based on slicer.

 

1. Create a parameter table to store month number.

2. Write a measure to check the current records based on filtered data range, then add tag to mark this record.

Tag =
VAR selected =
    SELECTEDVALUE ( 'Para Table'[Number] )
VAR current_date =
    MAX ( 'Table'[Date] )
RETURN
    IF (
        current_date
            >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - selected, DAY ( TODAY () ) )
            && TODAY ()
                <= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) + selected, DAY ( TODAY () ) ),
        1,
        0
    )


3. Drag this measure to visual level filter.

7.PNG

 

Result: previous 1 month to next 1 month

8.PNG

Notice: above measure will filter the date range previous X month to next X month.(X based on slicer)

 

Regards,

Xiaoxin Sheng

 

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @steph_io,

 

For your scenario, you can refer to below steps to filter based on slicer.

 

1. Create a parameter table to store month number.

2. Write a measure to check the current records based on filtered data range, then add tag to mark this record.

Tag =
VAR selected =
    SELECTEDVALUE ( 'Para Table'[Number] )
VAR current_date =
    MAX ( 'Table'[Date] )
RETURN
    IF (
        current_date
            >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - selected, DAY ( TODAY () ) )
            && TODAY ()
                <= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) + selected, DAY ( TODAY () ) ),
        1,
        0
    )


3. Drag this measure to visual level filter.

7.PNG

 

Result: previous 1 month to next 1 month

8.PNG

Notice: above measure will filter the date range previous X month to next X month.(X based on slicer)

 

Regards,

Xiaoxin Sheng

 

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.