Forum Discussion
rolf1994
9 years agoHelper II
Calculate value between two dates
Hi, i have the following tables in my data model (using directquery). I want to calculate the value in the ValueTable between the StartDate and EndDate. ValueTable: Date Value 25-2-2017 1 ...
- 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
Greg_Deckler
9 years agoCommunity Champion
Column = CALCULATE(SUM(ValueTable[Value]),FILTER(ValueTable,ValueTable[Date]>PeriodTable[StartDate] && ValueTable[Date]<PeriodTable[EndDate]))
- rolf19949 years agoHelper II
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?