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
yforti
Helper II
Helper II

Average over the past 6 months

Hi guys,

I'm having trouble calculating the average for the last 6 months.

I tried this measure and was unsuccessful: 

Msix month =AVERAGEX(DATESINPERIOD(visao_lancamento_setor_Tasy[DT_MOVIMENTO_ESTOQUE],LASTDATE(visao_lancamento_setor_Tasy[DT_MOVIMENTO_ESTOQUE]),-1,MONTH),[vlmovimento])

here's the example:
123123.JPG
The measure should calculate the average of the last 6 months for each NAME  (Nome column), in this example = "Alphamed". 

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

Hi @yforti ,

 

Are you trying to calculate average between last month and last 7 month? Would you please try the following measure:

Msix month =
AVERAGEX (
    DATESINPERIOD (
        visao_lancamento_setor_Tasy[DT_MOVIMENTO_ESTOQUE],
        EOMONTH ( visao_lancamento_setor_Tasy[DT_MOVIMENTO_ESTOQUE], -1 ),
        -7,
        MONTH
    ),
    [vlmovimento]
)

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

 

Best Regards,

Dedmon Dai

View solution in original post

3 REPLIES 3
v-deddai1-msft
Community Support
Community Support

Hi @yforti ,

 

Are you trying to calculate average between last month and last 7 month? Would you please try the following measure:

Msix month =
AVERAGEX (
    DATESINPERIOD (
        visao_lancamento_setor_Tasy[DT_MOVIMENTO_ESTOQUE],
        EOMONTH ( visao_lancamento_setor_Tasy[DT_MOVIMENTO_ESTOQUE], -1 ),
        -7,
        MONTH
    ),
    [vlmovimento]
)

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

 

Best Regards,

Dedmon Dai

yforti
Helper II
Helper II

@amitchandak i will try to explain myself better

This is my database currently used, the column (% Sector / General Faturavel) is a calculated measure.


Capturara.JPG

I need to find the (% Sector / General Faturavel) of the current month and compare it with the average of the (% Sector / General Faturavel) of the past 6 months.

I did the expected result in excel, see:
Capturar3333.JPG

 

As my database does not yet have data for February, the last month with data is January, so the calculation for the column (Sum 6 previous months)= Dec2020 + Nov2020 + Oct2020 + Sep2020 + Aug2020 + Jul2020.
After the sum of the past 6 months, I averaged this sum of values. This is what I need to do in BI.

To know:
Sum previous 6 months =SUM(D8:D13)
Average previous 6 months =AVERAGE(D8:D13)

amitchandak
Super User
Super User

@yforti , With help from date table

 

Rolling 6 = CALCULATE([vlmovimento],DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-6,MONTH))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

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.