Forum Discussion
nileshpca
4 years agoFrequent Visitor
calculate average from table with date wise price changes
to keep things simple, my table has date and price date of price change | price 01-Jan-21 | 22 04-Jan-21 | 20 16-Jan-21 | 18 22-Jan-21 | 21 average will calculate simple average of the four ...
- Anonymous4 years ago
Hi nileshpca ,
Here are the steps you can follow:
1. Create measure.
table1_sum = var _summtable= SUMMARIZE('Table 2','Table 2'[all date],'Table 2'[price], "price_change", var _1=CALCULATE(SUM('Table 2'[price]),FILTER(ALL('Table 2'),'Table 2'[all date]=EARLIER('Table 2'[all date]))) var _2=CALCULATE(SUM('Table 2'[price]),FILTER(ALL('Table 2'),'Table 2'[all date]=EARLIER('Table 2'[all date])-1)) return IF( _1<> _2,MINX(FILTER(ALL('Table 2'),'Table 2'[price]=EARLIER('Table 2'[price])),[price]),BLANK()), "count",COUNTX(FILTER(ALL('Table 2'),'Table 2'[price]=EARLIER('Table 2'[price])),[all date]), "count_all",COUNTX(ALL('Table 2'),[all date]), "sum_all",SUMX(ALL('Table 2'),[price])) return DIVIDE( SUMX(_summtable,[sum_all]),SUMX(_summtable,[count_all]))2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
amitchandak
4 years agoSuper User
If price is column
averageX(allselected(Table), Table[price])
if price is a measure
calculate(averageX(values(Table[Date], [price]), allselected())