Average() based on Start Date & End Date

Hello guys,

i need your help

how to calculate average by start date and end date?

This is the source table:

alhazen_0-1658016420475.png

and this is the table for calculation

alhazen_1-1658016553377.png

I used this formula, but it didn't work.

AVERAGE(
SELECT(
Sales[unit_sold],
AND(
[Product]=[Product],
[start_date]>=ANY(Sales[date]),
[end_date]<=ANY(Sales[date])
)
)
)

Thank you very much for your help.

Solved Solved
0 2 133
1 ACCEPTED SOLUTION

There may be other issues, but one detail is that likely you need to distinguish the references to the [Product] columns between the two tables. Analogously, you may likely need [_THISROW] also for your references to [start_date] and [end_date] columns. Within the SELECT function the default context for any column reference is the table from the function's first argument (e.g., Sales)--not the table where the expression happens to be.

[Product]=[_THISROW].[Product]  

 

View solution in original post

2 REPLIES 2

There may be other issues, but one detail is that likely you need to distinguish the references to the [Product] columns between the two tables. Analogously, you may likely need [_THISROW] also for your references to [start_date] and [end_date] columns. Within the SELECT function the default context for any column reference is the table from the function's first argument (e.g., Sales)--not the table where the expression happens to be.

[Product]=[_THISROW].[Product]  

 

Thank you very much

Top Labels in this Space