power bi calculating

Forum home » Delegate support and help forum » Microsoft Excel Training and help » POWER BI - calculating durations

POWER BI - calculating durations

resolvedResolved · High Priority · Version 365

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 courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Fill formulae across a sheet

To 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.

One reasonably quick way to copy an existing formula across a sheet is to select the formula and the cells on the right to which you want to copy it. Then press Ctrl+R to copy the formula across the selected range, or, if you are menu-minded, use the Edit|Fill|Right command.

View all Excel hints and tips


Server loaded in 0.06 secs.