cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Grouping years with dax for forecast

Hi,

 

I need to group my forecast count for all years before 2021 into the 2021 bucket. and then I will need to use this measure in a bar chart. 

 

So basically in the sample below I need to sum the values between 2015 - 2021 as 2021.

 

YearForecast
20155
20163
20174
20185
20191
20203
20215
20226
20238

Is this possible with dax?

 

Thank you

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

I write a measure for your reference, 

Total before 2021 =
VAR _startYear =
    CALCULATE ( MIN ( 'Table'[Year] ), ALL ( 'Table' ) )
VAR _thisYear =
    YEAR ( TODAY () )
RETURN
    IF (
        MIN ( 'Table'[Year] ) = _thisYear,
        CALCULATE (
            SUM ( 'Table'[Forecast] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Year] <= _thisYear
                    && 'Table'[Year] >= _startYear
            )
        )
    )

result

vxiaotang_0-1634618741002.png

 

if you need more help, please @ me.

 

 

Best Regards,

Community Support Team _Tang

If this post helps, 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-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

I write a measure for your reference, 

Total before 2021 =
VAR _startYear =
    CALCULATE ( MIN ( 'Table'[Year] ), ALL ( 'Table' ) )
VAR _thisYear =
    YEAR ( TODAY () )
RETURN
    IF (
        MIN ( 'Table'[Year] ) = _thisYear,
        CALCULATE (
            SUM ( 'Table'[Forecast] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Year] <= _thisYear
                    && 'Table'[Year] >= _startYear
            )
        )
    )

result

vxiaotang_0-1634618741002.png

 

if you need more help, please @ me.

 

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

MFelix
Super User
Super User

Hi @Anonymous 

 

Try the following measure:

 

Forecast = CALCULATE (SUM(Table[Forecast), FILTER(ALL(Table[Year]), Table[Year] >= 2015 && Table[Year] <= 2021))

 

This may need some adjustments depending on yout model setup.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors