cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
harib Member
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.

Capture.JPG

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-jiascu-msft Super Contributor
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.

Average-of-Current-and-Previous-Month

 

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.
v-jiascu-msft Super Contributor
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
Stachu Super Contributor
Super Contributor

Re: Average of Current and Previous Month

you could just do

Avg = ([MTD_Current_Volume]+[MTD_Previous_Volume])/2
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

harib Member
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

Stachu Super Contributor
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 =
    ADDCOLUMNS (
        SUMMARIZE ( Table, Table[DimPlant.PlantName] ),
        "Val", [MTD_Current_Volume]
    )
RETURN
    AVERAGEX ( __Plants, [Val] )

you just need to adjust the table name

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

Proud to be a Datanaut!

harib Member
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.

Capture.JPG

 

 

Thanks

Hari

v-jiascu-msft Super Contributor
Super Contributor

Re: Average of Current and Previous Month

Hi Hari,

 

What's the formula of [Volume_Total]? Please try this formula. If it doesn't work, please provide a sample of your original data. Please mask the sensitive parts first.

 

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
Super User

Re: Average of Current and Previous Month

Hi,

 

Share the link from where i can download your PBI file.

harib Member
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. 

 

 

Capture.JPG

v-jiascu-msft Super Contributor
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.

Average-of-Current-and-Previous-Month

 

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.
harib Member
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

 

 

Capture.JPG

 

 

Helpful resources

Announcements
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

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

Top Ideas
Users Online
Currently online: 129 members 1,479 guests
Please welcome our newest community members: