# Average of sum in KPI visualization for days with complete data

## Recommended Posts

I have the following data:

Date

A

B

C

Jan-1

100

Jan-1

200

Jan-1

50

Jan-2

75

Jan-2

50

Jan-3

110

Jan-3

30

Jan-3

100

Imagine that these arethree stores with sales data. I want to display the average of sales on those days where reports from all three stores have been received.

So I want to calculate the average of the sums for the days where I have complete data, i.e. the average for the sum on Jan-1 (350) and Jan-3 (240). Jan-2 should be ignored as the data is not yet complete. For this simple example the result shown in the KPI should be 295.

Can anyone point me into the right direction

##### Share on other sites

Assuming you have a fixed number of stores and column names, try this:

First collapse the sales amounts [A], and [C]into [ABC] calculated as:

Sum([A],,[C])

If(Count([Date]) OVER ([Date])=3,Sum([ABC]) over ([Date]),Null)

If your number of stores is variable, you could still calculate the Sum([A],,C],..) manually, but an idea could be to select the columns you want to consider as stores into a document property first and automate this step (and also modify the 3 into the number of stores).