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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

calculate the year average even when the drill down is monthly

Hello
I am trying to calculate the annual electricity expenditure target but I am only able to calculate monthly and not annually.
the annual target should be calculated by removing 3% of the value consumed in 2018. that is, in 2019 we subtract 3% in 2020 we subtract 6% ... and we divide this value by the number of pieces made.
after all this I do the average in the year the power bi is showing the value of 9.05 as the target for 2019 which is correct but when I drill down on the graph it shows me the monthly values and not a straight line with the value of 9.05.
I don't know if I managed to be clear.
please excuse my english. here's the simple ones from the file.
Thanks a lot for the help

1 ACCEPTED SOLUTION
SQLbyoBI
Advocate I
Advocate I


@Anonymous wrote:

Hello
I am trying to calculate the annual electricity expenditure target but I am only able to calculate monthly and not annually.
the annual target should be calculated by removing 3% of the value consumed in 2018. that is, in 2019 we subtract 3% in 2020 we subtract 6% ... and we divide this value by the number of pieces made.
after all this I do the average in the year the power bi is showing the value of 9.05 as the target for 2019 which is correct but when I drill down on the graph it shows me the monthly values and not a straight line with the value of 9.05.
I don't know if I managed to be clear.
please excuse my english. here's the simple ones from the file.
Thanks a lot for the help


If you want to see the value for the year when you drill down to the month level, you could change your calc to...

 
objective v2 =
VAR __current_yr =
    SELECTEDVALUE(
        calender[Year],
        MAX( 'calender'[Year] )
    )
VAR __retval =
    AVERAGEX(
        CALCULATETABLE(
            ALL( 'calender'[Month] ),
            REMOVEFILTERS( 'calender' ),
            'calender'[Year] = __current_yr
        ),
        CALCULATE(
            'Measure'[AverageofaMeasure]
        )
    )
RETURN
    __retval

 ... but for this to work, you need to rebuild your table using the Month/Year columns from *your* date table (not the ones from the auto-generated date table...

test.png

View solution in original post

1 REPLY 1
SQLbyoBI
Advocate I
Advocate I


@Anonymous wrote:

Hello
I am trying to calculate the annual electricity expenditure target but I am only able to calculate monthly and not annually.
the annual target should be calculated by removing 3% of the value consumed in 2018. that is, in 2019 we subtract 3% in 2020 we subtract 6% ... and we divide this value by the number of pieces made.
after all this I do the average in the year the power bi is showing the value of 9.05 as the target for 2019 which is correct but when I drill down on the graph it shows me the monthly values and not a straight line with the value of 9.05.
I don't know if I managed to be clear.
please excuse my english. here's the simple ones from the file.
Thanks a lot for the help


If you want to see the value for the year when you drill down to the month level, you could change your calc to...

 
objective v2 =
VAR __current_yr =
    SELECTEDVALUE(
        calender[Year],
        MAX( 'calender'[Year] )
    )
VAR __retval =
    AVERAGEX(
        CALCULATETABLE(
            ALL( 'calender'[Month] ),
            REMOVEFILTERS( 'calender' ),
            'calender'[Year] = __current_yr
        ),
        CALCULATE(
            'Measure'[AverageofaMeasure]
        )
    )
RETURN
    __retval

 ... but for this to work, you need to rebuild your table using the Month/Year columns from *your* date table (not the ones from the auto-generated date table...

test.png

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.