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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Anonymous
Not applicable

How to show the any 10 years data

Hi,

I have a report which connects to ADX data source through DirectQuery. We have data from 1950s. So, i guess my report will give performance issues with such a huge data(as the load method is DirectQuery). I want users to access the whole historic data but not all at a time. So they want to see any 10 years data at a time. 

 

Is there any way to have the date slicer in a "between " format and at the same time restrict the user to select only the dates before 10 years from the start date.?

 

Example:

If the user selects 01/01/1950 in the start date,the end date should show dates only upto 01/01/1960

If the user selects 01/01/2010 in the start date,the end date should show dates only upto 01/01/2020

 

Please help me.

Thanks,

Sai Priya.

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

Hi @Anonymous ,

You need  a data table and a date table ,they with no relationship between them.If you use a date in the data table as a slicer, then when you pick the value in the slicer, only one data for that date will be returned, so you need another date table.

Refer:

data_table = CALENDAR("1900,1,1","2021,1,1")
date_table = CALENDAR("1900,1,1","2021,1,1")

vluwangmsft_0-1646296281036.png

 

Then use the below measure:

TEST = 
IF (
    MAX ( 'data_table'[Date] )
        >= CALCULATE ( MIN ( 'date_table'[Date] ), ALLSELECTED ( 'date_table' ) )
        && MAX ( 'data_table'[Date] )
            <= DATE ( YEAR ( CALCULATE ( MIN ( 'date_table'[Date] ), ALLSELECTED ( 'date_table' ) ) ) + 10, MONTH ( CALCULATE ( MIN ( 'date_table'[Date] ), ALLSELECTED ( 'date_table' ) ) ), DAY ( CALCULATE ( MIN ( 'date_table'[Date] ), ALLSELECTED ( 'date_table' ) ) ) ),
    1,
    BLANK ()
)

 

Apply measure on filter:

vluwangmsft_1-1646296379313.png

 

Output:

When I choose   slicer:

vluwangmsft_2-1646296430436.png

Output maxdatevalue:

vluwangmsft_3-1646296454749.png

And when I choose 1922,the data table show the max date value is 1392:

vluwangmsft_4-1646296548112.png

 

 

You could download my pbix file if you need!

 

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


Best Regards

Lucien

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

You need  a data table and a date table ,they with no relationship between them.If you use a date in the data table as a slicer, then when you pick the value in the slicer, only one data for that date will be returned, so you need another date table.

Refer:

data_table = CALENDAR("1900,1,1","2021,1,1")
date_table = CALENDAR("1900,1,1","2021,1,1")

vluwangmsft_0-1646296281036.png

 

Then use the below measure:

TEST = 
IF (
    MAX ( 'data_table'[Date] )
        >= CALCULATE ( MIN ( 'date_table'[Date] ), ALLSELECTED ( 'date_table' ) )
        && MAX ( 'data_table'[Date] )
            <= DATE ( YEAR ( CALCULATE ( MIN ( 'date_table'[Date] ), ALLSELECTED ( 'date_table' ) ) ) + 10, MONTH ( CALCULATE ( MIN ( 'date_table'[Date] ), ALLSELECTED ( 'date_table' ) ) ), DAY ( CALCULATE ( MIN ( 'date_table'[Date] ), ALLSELECTED ( 'date_table' ) ) ) ),
    1,
    BLANK ()
)

 

Apply measure on filter:

vluwangmsft_1-1646296379313.png

 

Output:

When I choose   slicer:

vluwangmsft_2-1646296430436.png

Output maxdatevalue:

vluwangmsft_3-1646296454749.png

And when I choose 1922,the data table show the max date value is 1392:

vluwangmsft_4-1646296548112.png

 

 

You could download my pbix file if you need!

 

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


Best Regards

Lucien

jaipal
Resolver III
Resolver III

Anonymous
Not applicable

Thanks Jaipal, I got the answer.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.