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

how to calculate future 6 months values

Hello All,

I have a requirement to show the sum of future 6 months from the selected month
let’s says we are selecting October then I need to calculate from Nov, Dec, Jan, Feb, March, Apr
Thanks
Prashanth

 

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

Hi @Prasala583 ,

 

According to your description, you want to calculate the sum of the following six months based on the selected month. But I think you are missing the element of year.

 

Here's my solution.

Sample data

vstephenmsft_2-1639636296009.png

 

 

1.Create a calendar table. There's no relationship between tables.

Calendar =
ADDCOLUMNS (
    CALENDAR ( DATE ( 2021, 1, 1 ), DATE ( 2021, 12, 31 ) ),
    "YearMonth", FORMAT ( [Date], "YYYY-MM" )
)

vstephenmsft_0-1639636231881.png

vstephenmsft_1-1639636239225.png

 

2.Create a measure.

Sum of next 6 months = 
VAR _mon =
    VALUE ( RIGHT ( SELECTEDVALUE ( 'Calendar'[YearMonth] ), 2 ) )
VAR _yea =
    VALUE ( LEFT ( SELECTEDVALUE ( 'Calendar'[YearMonth] ), 4 ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        DATESINPERIOD ( 'Table'[Date], DATE ( _yea, _mon + 1, 1 ), 5, MONTH )
    )

 

3.Create a slicer with YearMonth field, a table visual with ID fild and the measure. This is the result.

vstephenmsft_3-1639636318971.png

 

Check the attachment for more details.

 

 

Best Regards,

Stephen Tao

 

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-stephen-msft
Community Support
Community Support

Hi @Prasala583 ,

 

According to your description, you want to calculate the sum of the following six months based on the selected month. But I think you are missing the element of year.

 

Here's my solution.

Sample data

vstephenmsft_2-1639636296009.png

 

 

1.Create a calendar table. There's no relationship between tables.

Calendar =
ADDCOLUMNS (
    CALENDAR ( DATE ( 2021, 1, 1 ), DATE ( 2021, 12, 31 ) ),
    "YearMonth", FORMAT ( [Date], "YYYY-MM" )
)

vstephenmsft_0-1639636231881.png

vstephenmsft_1-1639636239225.png

 

2.Create a measure.

Sum of next 6 months = 
VAR _mon =
    VALUE ( RIGHT ( SELECTEDVALUE ( 'Calendar'[YearMonth] ), 2 ) )
VAR _yea =
    VALUE ( LEFT ( SELECTEDVALUE ( 'Calendar'[YearMonth] ), 4 ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        DATESINPERIOD ( 'Table'[Date], DATE ( _yea, _mon + 1, 1 ), 5, MONTH )
    )

 

3.Create a slicer with YearMonth field, a table visual with ID fild and the measure. This is the result.

vstephenmsft_3-1639636318971.png

 

Check the attachment for more details.

 

 

Best Regards,

Stephen Tao

 

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

 

amitchandak
Super User
Super User

@Prasala583 , With help from date table and time intelligence

Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-6 ,MONTH))

 

but if you want a trend, you need independent table 

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

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.