Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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
26-2-2017 1
27-2-2017 1
28-2-2017 1
1-3-2017 1
2-3-2017 1
3-3-2017 1
4-3-2017 1
5-3-2017 1
PeriodTable:
StartDate EndDate
1-2-2017 28-2-2017
1-3-2017 31-3-2017
The outcome of the formule should look like this:
1-2-2017 - 28-2-2017 = 4
1-3-2017 - 31-3-2017 = 5
Could someone help me with this?
Solved! Go to Solution.
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. ![]()
Measure =
CALCULATE (
SUM ( ValueTable[Value] ),
FILTER (
ValueTable,
ValueTable[Date] >= MIN( PeriodTable[StartDate] )
&& ValueTable[Date] <= MAX ( PeriodTable[EndDate] )
)
)
Regards
ok, i found my way.
Its not elegant, but works.
First I created two measures:
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
I created a column and it was in the PeriodTable table.
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. ![]()
Measure =
CALCULATE (
SUM ( ValueTable[Value] ),
FILTER (
ValueTable,
ValueTable[Date] >= MIN( PeriodTable[StartDate] )
&& ValueTable[Date] <= MAX ( PeriodTable[EndDate] )
)
)
Regards
This worked well for me thank you 🙏 @v-ljerr-msft just have one additional question. How would you write this to show the output as 0 for counts where there is no date values just yet?
I have the same but opposite setup on my tables, how would you write the measure if the periods are on the values table and the and the second table is a single date point, where you wanted to get the sum of all values where the single date falls in-between the start and end dates?
ie.
Date Table:
Date
1/15/2018
2/15/2018
3/15/2018
Values Table
Start | End | Value
1/01/18 | 1/31/18 | 1
1/13/18 | 3/12/18 | 1
2/14/18 | 3/13/18 | 1
so i would be looking for a result like this:
Date | Sum
1/15/18 | 2
2/15/18 | 2
Thanks
(let me know if this is too offtopic and I will start a new thread)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |