Forum Discussion
Calculate date range when specific value is reached
- 3 years ago
Create a one-to-many relationship from the company table to the summary table, then add a new calculated column to the company table,
Date reached 30 = CALCULATE ( MIN ( 'Summary Table'[Date] ), 'Summary Table'[@cumulative commission] >= 30 )You can then create a measure like
Avg time to 30 = AVERAGEX ( FILTER ( Company, NOT ISBLANK ( Company[Date reached 30] ) ), DATEDIFF ( Company[Create date], Company[Date reached 30], DAY ) )
You can try and create a summary table, like
Summary Table =
ADDCOLUMNS (
SUMMARIZE ( 'Transactions', 'Transactions'[Company ID], 'Transactions'[Date] ),
"@cumulative commission",
VAR CurrentDate = 'Transactions'[Date]
VAR Result =
CALCULATE (
SUM ( 'Transactions'[Commission] ),
REMOVEFILTERS ( 'Transactions'[Date] ),
'Transactions'[Date] <= CurrentDate
)
RETURN
Result
)
This will calculate the cumulative commission for each company for each date which that company has transactions for. If that is successful then we can use that summary table to find the minimum date where the cumulative commission is above the threshold.
- AntonV3 years ago
Helper I
johnt75 I was able to generate the summary table, but how do I now calculate the date when a company reaches €30?
And how do I calculate the average duration that it takes to get there for all companies?
Thanks in advance. You are a life saver!!
- johnt753 years ago
Super User
Create a one-to-many relationship from the company table to the summary table, then add a new calculated column to the company table,
Date reached 30 = CALCULATE ( MIN ( 'Summary Table'[Date] ), 'Summary Table'[@cumulative commission] >= 30 )You can then create a measure like
Avg time to 30 = AVERAGEX ( FILTER ( Company, NOT ISBLANK ( Company[Date reached 30] ) ), DATEDIFF ( Company[Create date], Company[Date reached 30], DAY ) )- AntonV3 years ago
Helper I
johnt75 Thanks a lot for the help. I found what I needed.
I do need to make one more calculation, but I am not sure if it's appropriate to keep asking you questions. If not, you can ingnore my message! A million thanks either way
What I now need to calculate with the same tables is: "How mutch commission is collected under the €30 bar for each year?"
Here you have some use cases:
- Company 1:
- Y1: €50 commission
- Only €30 should be included in the calculation
- Company 2:
- Y1: €10 commission
- Y2: €40 commission
- Only €30 (€10 + €20) should be included in the calculation
- Company 3:
- Y1: €0 commission
- Y2: €10 commission
- Only €10 should be included in the calculation.
Based on this I need a total of all commissions earned under €30 per company per year. Hope my explenation is clear...
Again really appreciate the help and I hope you have time to help me a little further..
- Company 1: