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

Attn Power BI ninjas: Custom Date Range Inquiry

Greetings Power BI ninjas! I am a new Power BI user and need some assistance from the community. I am trying to create a custom date range that will go back 15 years from the date that I manually select.

 

Target result: I want to have a drop down selection where I pick a year, the selected year will calculate back the selected year + 15 years prior.

 

Current problem: The closest thing that I can get to this is a sliding date scale but my ultimate target is to just have a drop down where I can select a year and it will calculate that selected year + 15 years prior just like what the sliding date scale is accomplishing (please see screenshot below for reference)

 

As a new user, I am a true noob and welcome any advise. Please be advised that as a true noob, your welcomed advice might literally have to be spelled out in steps for me.

Help a brotha out pls!

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

You can create an extra table which is unrelated to source data table, to list all available year selections.

Year selection =
FILTER (
    CALENDAR ( DATE ( 1980, 1, 1 ), DATE ( 2020, 1, 1 ) ),
    MONTH ( [Date] ) = 1
        && DAY ( [Date] ) = 1
)

1.PNG

 

Later, please add this [date] field into slicer.

 

Create below measure and add it to visual level filter, set its value to 1.

flag =
IF (
    MAX ( 'Sheet1 (2)'[Year] ) <= YEAR ( SELECTEDVALUE ( 'Year selection'[Date] ) )
        && MAX ( 'Sheet1 (2)'[Year] )
            > YEAR ( SELECTEDVALUE ( 'Year selection'[Date] ) ) - 15,
    1,
    0
)

2.PNG

 

Best regards,

Yuliana Gu

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

View solution in original post

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

You can create an extra table which is unrelated to source data table, to list all available year selections.

Year selection =
FILTER (
    CALENDAR ( DATE ( 1980, 1, 1 ), DATE ( 2020, 1, 1 ) ),
    MONTH ( [Date] ) = 1
        && DAY ( [Date] ) = 1
)

1.PNG

 

Later, please add this [date] field into slicer.

 

Create below measure and add it to visual level filter, set its value to 1.

flag =
IF (
    MAX ( 'Sheet1 (2)'[Year] ) <= YEAR ( SELECTEDVALUE ( 'Year selection'[Date] ) )
        && MAX ( 'Sheet1 (2)'[Year] )
            > YEAR ( SELECTEDVALUE ( 'Year selection'[Date] ) ) - 15,
    1,
    0
)

2.PNG

 

Best regards,

Yuliana Gu

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

Thank you so much! 

Arentir
Resolver III
Resolver III

Welcome to the Power BI dojo @Anonymous 🙂

 

There are probably several approachea, I think this solution should fit your need alright.

 

You can have a new calculated table with two columns:

- "Year anchor"  that will be your slicer

-  "Year", that will have a relationship to your date table or whatnot

 

This formula will generate a table where each year anchor will have 15 rows (year -15 up to year anchor)

 

Table =
FILTER(
CROSSJOIN(
SELECTCOLUMNS(GENERATESERIES(2000,2015,1),"YearAnchor",[Value]),
SELECTCOLUMNS(GENERATESERIES(1985,2015,1),"Year",[Value])
), AND([Year] >= ([YearAnchor] - 15), [Year] <= [YearAnchor])
)

 

Hope this helps!

 

image.png

Arentir

Anonymous
Not applicable

thank you so much!

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.