98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel Training and help » POWER BI - calculating durations
POWER BI - calculating durations
Resolved · High Priority · Version 365
Brett has attended:
Power BI Modelling, Visualisation and Publishing course
POWER BI - calculating durations
Hello
I have a table that contains Deal ID (unique value), date of deal, Activity ID (unique values) and date of activity. There is a one to many relationship between Deal ID and Activity ID.
I want to calculate the time between date of deal and date of activity, but only for the first completed activity of each deal.
Deal ID Date of deal Activity ID Date of activity
A 01/01/2019 1 06/01/2019
A 01/01/2019 2 03/01/2019
A 01/01/2019 3 15/02/2019
B 02/03/2019 4 04/03/2019
B 02/03/2019 5 08/03/2019
C 16/02/2019 6 25/02/2019
C 16/02/2019 7 20/02/2019
C 16/02/2019 8 21/02/2019
C 16/02/2019 9 28/02/2019
In the above example, Deal A has 3 associated activities, and Activity 2 was the first completed activity
Deal B has 2 associated activities, and Activity 4 was the first completed activity
Deal C has 4 associated activities, and Activity 7 was the first completed activity
The reason I'm asking is that we have a KPI that says any activity must be within 2 days of deal date - so I'm only interested on the first activity. Does that make sense?
RE: POWER BI - calculating durations
Hi Brett,
Thank you for the forum question.
To got the date of the first activity I created a column calculation in the many table (the table where you have the data above) see dax below. The dax will return the first date for each activity for each deal id. You then just need to calculate [FirstActivity]-[Date of Deal]
FirstACtivity = CALCULATE(MIN(Table1[Date of Activity]),FILTER(Table1,Table1[Deal Id]=EARLIER(Table1[Deal Id])))
I hope this makes sense.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Fri 8 Mar 2019: Automatically marked as resolved.
Training information:
See also:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Fill formulae across a sheetTo copy a formula down a spreadsheet where there is data underneath, to the left or to the right of the formula, double-click on the fill handle. The fill handle is the little black cross that appears in the bottom right-hand corner of the formula cell. Unfortunately, no similar facility exists to copy formulae across the sheet. |