Forum Discussion
Calculate value between two dates
- 9 years ago
Hi rolf1994,
You should be able to use the formula below to create a measure in this scenario, then show the measure on the Table/Matrix visual with PeriodTable[StartDate] and PeriodTable[EndDate] column. :smileyhappy:
Measure = CALCULATE ( SUM ( ValueTable[Value] ), FILTER ( ValueTable, ValueTable[Date] >= MIN( PeriodTable[StartDate] ) && ValueTable[Date] <= MAX ( PeriodTable[EndDate] ) ) )Regards
Column = CALCULATE(SUM(ValueTable[Value]),FILTER(ValueTable,ValueTable[Date]>PeriodTable[StartDate] && ValueTable[Date]<PeriodTable[EndDate]))
Thanks for your answer. i get the following error when i try to create the measure:
A single value for column 'StartDate' in table 'PeriodTable' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result
- Greg_Deckler9 years agoCommunity Champion
I created a column and it was in the PeriodTable table.
- rolf19949 years agoHelper III cannot use the calculate function when creating a new column in directquery mode. Is there any other way?
- v-ljerr-msft9 years agoMicrosoft Employee
Hi rolf1994,
You should be able to use the formula below to create a measure in this scenario, then show the measure on the Table/Matrix visual with PeriodTable[StartDate] and PeriodTable[EndDate] column. :smileyhappy:
Measure = CALCULATE ( SUM ( ValueTable[Value] ), FILTER ( ValueTable, ValueTable[Date] >= MIN( PeriodTable[StartDate] ) && ValueTable[Date] <= MAX ( PeriodTable[EndDate] ) ) )Regards