Forum Discussion
calculate average from table with date wise price changes
- 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
Hi:
I have created another way to get to yout initial question.
Power Query(example#1) is the best for lot's of items and changes.
So far we have three different solutions to your original question.
If you want to post a new question with new data.
Here is the file link with the various solutions.
Thanks!https://drive.google.com/file/d/1Qc6dQnkbNHkwAZeoh5eCdeI78JUDblmz/view?usp=sharing
thanks a lot. i am using powerquery currently, but only for 2-3 products. there are 50 + products over 6 years. the pq table will be huge drain on memory.
was thinking is it possible to create virtual table in dax with date column from calender and product selected from filter row and then fill down in the virtual table.
that would be awesome, if it can happen...