Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello,
I need some help calculating a duration of a job ID only for one unique ID.
Current
This is what I have currently. Each ID returns a duration in the calculated column.
ID | Start time | End time | Duration |
111 | 08:00:00 | 09:30:00 | 01:30:00 |
111 | 08:00:00 | 09:30:00 | 01:30:00 |
234 | 10:30:00 | 11:00:00 | 00:30:00 |
234 | 10:30:00 | 11:00:00 | 00:30:00 |
234 | 10:30:00 | 11:00:00 | 00:30:00 |
234 | 10:30:00 | 11:00:00 | 00:30:00 |
Required
This is what is requred. Each unique ID returns only one duration in the calculated column.
ID | Start time | End time | Duration |
111 | 08:00:00 | 09:30:00 | 01:30:00 |
111 | 08:00:00 | 09:30:00 | |
234 | 10:30:00 | 11:00:00 | 00:30:00 |
234 | 10:30:00 | 11:00:00 | |
234 | 10:30:00 | 11:00:00 | |
234 | 10:30:00 | 11:00:00 |
Solved! Go to Solution.
Hi @DRossi ,
First, create a index column in the Power Query.
Second, create the calculated column.
Duration =
VAR tt =
RANKX (
FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
[Index],
,
ASC,
DENSE
)
RETURN
IF ( tt = 1, [End time] - [Start time] )
You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @DRossi ,
First, create a index column in the Power Query.
Second, create the calculated column.
Duration =
VAR tt =
RANKX (
FILTER ( 'Table', 'Table'[ID] = EARLIER ( 'Table'[ID] ) ),
[Index],
,
ASC,
DENSE
)
RETURN
IF ( tt = 1, [End time] - [Start time] )
You can check more details from here.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Smashed it @Anonymous thanks so much.
@DRossi ,
If you ingest your data into power BI so it will automatically show only unique records. Just create Calculated Column like below:
Hi @Tahreem24 , Unfortuantely it isn't as simple as that. The other rows and columns within the ID hold important information that I haven't shown.
I did attempt using this from a similar thread but struggled to modify:
Solved: Indexing rows by a distinct values and then gettin... - Microsoft Power BI Community
@DRossi ,
I provided the solution based on the info you have shared. You should have shared in your post regarding more fields as a dummy entry.
User | Count |
---|---|
84 | |
76 | |
75 | |
43 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |