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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jolazar
New Member

Calculated grouped average based on context filters and apply if condition to count rows

Hello!

I'm trying to calculate an average table grouped by store. Once I've calculated it I would like to assign to this average number a codition and count the numbers of stores that matches it.

This is my aggregate average table that I've calculated in powerbi

jolazar_0-1669913755860.png

on the yellow number I would like to assign different categories based on condition and count the stores that fall in it. The problem is that I want to count stores based on this new aggregated measure and not on the original table (and PBI doesn't automatically do it). I've also tried to create a new table with average values already computed but then it doesn't change when I apply context filters. To sum up, I would like to calculate a rolling average according to context filter date applied and on this computed valued count the stores that falls within some ranges.

This is the DAx I've used 

 

GROUPBY(
    Table,
    Table[STORE],
    Table[DATE_LOCAL],
    "CLASS", AVERAGEX ( CURRENTGROUP(),Table[CLASS])
)



Any help??

 

 

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

Hi @jolazar ,

 

If you want to calculate the rolling values based on stores, you'd better have an index column or other columns you could calculate based on it.

Rolling Average = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLSELECTED('Table'),[Index]<=MAX('Table'[Index])))

vstephenmsft_1-1669969824646.png

If your store names are in a certain order, you can also refer to the store.

Rolling Average1 = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLSELECTED('Table'),[Store]<=MAX('Table'[Store])))

vstephenmsft_2-1669969893250.png

If you are still in doubt, it is best to provide some sample data along with the expected results. Remember to protect privacy.

 

 

 

Best Regards,

Stephen Tao

 

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

1 REPLY 1
v-stephen-msft
Community Support
Community Support

Hi @jolazar ,

 

If you want to calculate the rolling values based on stores, you'd better have an index column or other columns you could calculate based on it.

Rolling Average = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLSELECTED('Table'),[Index]<=MAX('Table'[Index])))

vstephenmsft_1-1669969824646.png

If your store names are in a certain order, you can also refer to the store.

Rolling Average1 = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLSELECTED('Table'),[Store]<=MAX('Table'[Store])))

vstephenmsft_2-1669969893250.png

If you are still in doubt, it is best to provide some sample data along with the expected results. Remember to protect privacy.

 

 

 

Best Regards,

Stephen Tao

 

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.