cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AkrMus Regular Visitor
Regular Visitor

Average with Group by DAX

Hi

I have this data

 

myRate | myDate

7           | 1 Feb 2019

3           | 14 Feb 2019

9           | 1 Feb 2019

4           | 4 Mar 2019

6           | 11 Apr 2019

3           | 13 Mar 2019

8           | 9 Feb 2019

2           | 2 Apr 2019

6           | 1 Feb 2019

5           | 2 Apr 2019

1           | 21 Feb 2019

9           | 18 Mar 2019

3           | 30 Mar 2019

 

 How in DAX I can get a new column that Shows this

 

New_Column = Average of Rates to the same months

 

my Daya will ook like this

 

myRate | myDate           | myAvg

7           | 1 Feb 2019      | 5.66

3           | 14 Feb 2019    | 5.66

9           | 1 Feb 2019      | 5.66

4           | 4 Mar 2019      | 4.75

6           | 11 Apr 2019    | 4.33

3           | 13 Mar 2019   | 4.75

8           | 9 Feb 2019      | 5.66

2           | 2 Apr 2019      | 4.33

6           | 1 Feb 2019      | 5.66

5           | 2 Apr 2019      | 4.33

1           | 21 Feb 2019    | 5.66

9           | 18 Mar 2019   | 4.75

3           | 30 Mar 2019   | 4.75

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Average with Group by DAX

hi, @AkrMus 

If you want it could be filtered by myRate , just try this formula

Measure = calculate(average( 'Table'[myRate]), FILTER(ALLSELECTED('Table'),'Table'[Month]=MAX('Table'[Month])))

Result:

9.JPG10.JPG

 

Best Regards,

Lin

 

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

View solution in original post

5 REPLIES 5
Highlighted
chrischiappazzo Regular Visitor
Regular Visitor

Re: Average with Group by DAX

Create a new column and put your column titles in the appropriate spots i have put in bold

 

Average = calculate(average( my rate column), ALLEXCEPT(table name, my date column)

 

 

AkrMus Regular Visitor
Regular Visitor

Re: Average with Group by DAX

Thanks,

 

But when I fliter through Slicer, the average still for the whole data without filter!!

 

How can I fix that to consider filter when find the average of the month?

Community Support Team
Community Support Team

Re: Average with Group by DAX

hi, @AkrMus 

First, you should know that calculated column and calculate table can't be affected by any slicer. you could create a measure
Notice:
1. Calculation column/table not support dynamic changed based on filter or slicer.
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result.
here is reference:
https://community.powerbi.com/t5/Desktop/Different-between-calculated-column-and-measure-Using-SUM/t...
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

Second, for your requirement,

you need to add a month column (or year-month column) 

Then use “all” functions to create a measure

Measure = calculate(average( 'Table'[myRate]), ALLEXCEPT('Table','Table'[Month]))

Then drag month field into table visual( set this field don't summarize)

Result:

1.JPG

and here is pbix file, please try it.

 

Best Regards,

Lin

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

Re: Average with Group by DAX

Many thanks for your reply

 

I have tried the file you uploaded

 

the Mesaure average does not change based on the slicer 😞

 

I added slicer for myRate and filtered data for myRate > 5

there was no change on the calculated column or the Measure

 

 

Community Support Team
Community Support Team

Re: Average with Group by DAX

hi, @AkrMus 

If you want it could be filtered by myRate , just try this formula

Measure = calculate(average( 'Table'[myRate]), FILTER(ALLSELECTED('Table'),'Table'[Month]=MAX('Table'[Month])))

Result:

9.JPG10.JPG

 

Best Regards,

Lin

 

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

View solution in original post

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)