Forum Discussion

thomsontam's avatar
thomsontam
Frequent Visitor
5 years ago
Solved

Rolling Average Distinct count question

Hi,

 

I got a huge data set with 7m+ rows with the data like the following:

CompanyProductCountryUnitDate
1AAU11/07/2020
1BNZ11/07/2020
2ANZ11/07/2020
2BAU11/07/2020
3AAU11/07/2020
3CNZ11/07/2020
4BAU11/07/2020
5CAU11/07/2020
6AAU11/07/2020
6BAU11/07/2020
6CAU11/07/2020

 

I am able to create 90 Days running average on unit using the follow formula:

 

CALCULATE((Sum(table1[Unit]))/90,
DATESBETWEEN(table1[Date],
MAX(table1[Date]) - 89 ,
MAX(table1[Date]))

 

90 Days running average on customer count by

# of A  = 

Calculate(DistinctCount(Table1[Customer]),
FILTER(Table1,table1[Product]="A")
)

# of B = 

Calculate(DistinctCount(Table1[Customer]),
FILTER(Table1,table1[Product]="B")
)

 

# of A Avg 90D =
AVERAGEX(
DATESBETWEEN(table1[Date],
MAX(table1[Date]) - 89,
MAX(table1[Date])),table1[# of A]
)

 

# of B Avg 90D =
AVERAGEX(
DATESBETWEEN(table1[Date],
MAX(table1[Date]) - 89,
MAX(table1[Date])),table1[# of B]
)

 

A vs B Ratio 90D =
DIVIDE([# of A Avg 90D], [# of B Avg 90D])

 

All calculates are working on a small dataset but failed to load once data over 3m rows and took long time to refresh when change in filter.

 

Could you please give me some suggest how I should reformat the data ?

 

We need to do a lot of ratio analysis on product in difference country so I created a lot of individual measure for each product...

 

Thanks a lot!

3 Replies