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
amunshi
Frequent Visitor

Show next 5 years data.

Hi.

I want to display next 5 years data according to the slicer selection.
For example, if I select 2016 in the slicer then my matrix should show Total Sales for next 5 years viz(2017,2018,2019,2020,2021).
Any help would be appreciated.

 

Regards,

Ashlesha

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @amunshi ,

 

According to your description, I did the following tests:

M_ =
VAR a =
    YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            YEAR ( 'Table'[Date] ) > a
                && YEAR ( 'Table'[Date] ) < a + 5
        )
    )

vhenrykmstf_0-1634106876579.png


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

Hi @amunshi ,

 

According to your description, I did the following tests:

M_ =
VAR a =
    YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            YEAR ( 'Table'[Date] ) > a
                && YEAR ( 'Table'[Date] ) < a + 5
        )
    )

vhenrykmstf_0-1634106876579.png


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

HI @amunshi 

 

You need to use a measure and date table; I don't know how your data looks like, but try something like this:

 

measure=
Var _SD=selectedvalue[Date column form date table in the slicer])
Var _SD5 = _SD+5
return
calculate(sum([Sales],filter(table, [date]>=_SD&&[date]<=_SD5))

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!



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.