cancel
Showing results for
Did you mean:
Member

## Average of Current and Previous Month

I have a table like below and created the Measures like MTD_Current_Volume  and MTD_Previous_Volume .Now i need  individual Average of current and previous month of volume in diffrent columns like avg Current month and avg previous month.

MTD_Current_Volume = TOTALMTD([Volume_Total],DATESMTD(WHIN_Sales[DimDate.Date]))

MTD_Previous_Volume = CALCULATE([Volume_Total], PREVIOUSMONTH(DATESMTD(WHIN_Sales[DimDate.Date])))

Above formulas are which i have used in the DAX. i'm not able to get the average of both the measure. appriciate if anyone get the answer.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super Contributor

## Re: Average of Current and Previous Month

Hi @harib,

It seems the first one doesn't return the right value. Please check out.

You'd like the results of the previous month, but you don't have a date context. What should the previous month be?

Please refer to the demo in the snapshot. If I don't make any selection, the previous is out of range of the date table.

Please try it and verify the results.

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super Contributor

## Re: Average of Current and Previous Month

Hi @harib,

My pleasure.

Let's take the below scenario as an example. There are only two records in October. The AVERAGE function will return (100 + 210) / 2 = 155 while (100 + 210) / 31 = 10. Which one do you prefer? Can you hardcode the 31? If you have the answers to these two questions, the solution could be clear.

2018-10-01   100

2018-10-02   210

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
11 REPLIES 11
Super Contributor

## Re: Average of Current and Previous Month

you could just do

`Avg = ([MTD_Current_Volume]+[MTD_Previous_Volume])/2`

Proud to be a Datanaut!

Member

## Re: Average of Current and Previous Month

@Stachu

i need individual Average of current and previous month of volume in diffrent columns like avg Current month and avg previous month.

Thanks for your quick responce.appriciate if you can come up with solution of above msg

Super Contributor

## Re: Average of Current and Previous Month

I'm guessing you need the average per plant, if that's the case something like this should work:

```Avg Current Month =
VAR __Plants =
SUMMARIZE ( Table, Table[DimPlant.PlantName] ),
"Val", [MTD_Current_Volume]
)
RETURN
AVERAGEX ( __Plants, [Val] )```

you just need to adjust the table name

Proud to be a Datanaut!

Member

## Re: Average of Current and Previous Month

@Stachu

Hi Stachu, i need output like below table. I got average but used below dax function .

MTD_Current_Volume_Avg = [MTD_Current_Volume]/21.

MTD_Previous_Volume_Avg = [MTD_Previous_Volume]/31.

but this is not the correct way and the one which you have given also not working. Can u check below image for refrence.

Thanks

Hari

Super Contributor

## Re: Average of Current and Previous Month

Hi Hari,

```MTD_Current_Volume_Avg =
AVERAGEX ( 'table', [Volume_Total] )
```
```MTD_Previous_Volume_Avg =
CALCULATE (
[MTD_Current_Volume_Avg],
PREVIOUSMONTH ( whin_sales[dimdate.date] )
)
```

I would suggest you use an independent Date table.

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User

Hi,

Member

## Re: Average of Current and Previous Month

@v-jiascu-msft

Thanks for your reply . 1st formula is worked fine but the second is not working. Attached screen shot.

Super Contributor

## Re: Average of Current and Previous Month

Hi @harib,

It seems the first one doesn't return the right value. Please check out.

You'd like the results of the previous month, but you don't have a date context. What should the previous month be?

Please refer to the demo in the snapshot. If I don't make any selection, the previous is out of range of the date table.

Please try it and verify the results.

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Member

## Re: Average of Current and Previous Month

@v-jiascu-msft

HI Dale,

Thank you very much for your solution, but results are coming diffrent  when compare to below two measure. I have attached screen shot. Please clear this. Thanks in Advance

MTD_Previous_Volume_Avg :

CALCULATE ([MTD_Current_Volume_Average],
PREVIOUSMONTH ( whin_sales[dimdate.date] )
)

MTD_PreviousMonth_Avg = [MTD_Previous_Volume]/31

Announcements

#### Back to School Contest

Engage and empower students with Power BI!

#### Watch Sessions On Demand!

Continue your learning in our online communities.

#### Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

#### PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 129 members 1,479 guests
Recent signins: