Forum Discussion
date table
- 5 years ago
Hi Anonymous ,
First create a column in query 2:
next period = var _next= CALCULATE(MIN('Table'[Date]),FILTER('Table','Table'[Date]>EARLIER('Table'[Date])&&'Table'[Product]=EARLIER('Table'[Product]))) Return IF(_next=BLANK(),DATE(YEAR(MAX('Table'[Date])),12,31),_next)Then create a measure as below:
_cost = CALCULATE(MIN('Table'[Price]),FILTER('Table','Table'[Date]<=MAX('Query 1'[Date])&&'Table'[next period]>=MAX('Query 1'[Date])&&'Table'[Product]=MAX('Query 1'[Product])))And you will find that the price has been added to query 1 according to period setting.
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
hi amitchandak
thanks for quick reply, i used your method, but it partially worked... the difficulty is to have a changing price between period, if i use your method, on my new column i only have the data i need at one date vs all date (in order to calculate turnover etc).
Hi Anonymous ,
First create a column in query 2:
next period =
var _next= CALCULATE(MIN('Table'[Date]),FILTER('Table','Table'[Date]>EARLIER('Table'[Date])&&'Table'[Product]=EARLIER('Table'[Product])))
Return
IF(_next=BLANK(),DATE(YEAR(MAX('Table'[Date])),12,31),_next)
Then create a measure as below:
_cost =
CALCULATE(MIN('Table'[Price]),FILTER('Table','Table'[Date]<=MAX('Query 1'[Date])&&'Table'[next period]>=MAX('Query 1'[Date])&&'Table'[Product]=MAX('Query 1'[Product])))
And you will find that the price has been added to query 1 according to period setting.
For the related .pbix file,pls see attached.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!