The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Given the columns: vendor, startdate, and duration, is there a way to return the the maximum count of simultaneous tasks?
example:
Vendor A | 5/1/2020 | 7 |
Vendor A | 5/2/2020 | 7 |
Vendor A | 5/15/2020 | 7 |
Vendor A | 6/1/2020 | 7 |
Vendor B | 5/1/2020 | 5 |
Vendor B | 5/15/2020 | 5 |
Vendor B | 5/17/2020 | 5 |
Vendor B | 5/18/2020 | 5 |
Vendor C | 6/1/2020 | 10 |
Vendor C | 6/20/2020 | 10 |
Vendor A will have a maximum of 2 tasks happening at the same time.
Vendor B will have a maximum of 3 tasks happening at the same time.
Vendor C will have a maximum of 1 task happening at the same time.
In the attached pbix example I have a similar table with more instances, along with a date table.
Solved! Go to Solution.
Hi @klintala ,
Try this:
1. Create [EndDate] column.
EndDate = [StartDate]+[Duration]
2. Create a Measure.
Measure =
VAR t1 =
SELECTCOLUMNS (
'Table',
"Vendor_", 'Table'[Vendor],
"StartDate_", 'Table'[StartDate],
"EndDate_", 'Table'[EndDate]
)
VAR t2 =
FILTER (
CROSSJOIN ( 'Table', t1 ),
[Vendor] = [Vendor_]
&& NOT ( [EndDate] <= [EndDate_] )
)
VAR t3 =
ADDCOLUMNS (
t2,
"MinDate_", IF ( [StartDate] >= [StartDate_], [StartDate], [StartDate_] ),
"MaxDate", IF ( [EndDate] >= [EndDate_], [EndDate_], [EndDate] )
)
VAR t4 =
ADDCOLUMNS ( t3, "OverlapDay", DATEDIFF ( [MinDate_], [MaxDate], DAY ) )
VAR t5 =
ADDCOLUMNS (
t4,
"Count_", COUNTAX (
FILTER (
t4,
[Vendor] = EARLIER ( [Vendor] )
&& [StartDate] = EARLIER ( [StartDate] )
&& [OverlapDay] > 0
),
[Vendor]
)
)
RETURN
MAXX ( t5, [Count_] + 1 )
For more details, please check the attached PBIX file,
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @klintala ,
Try this:
1. Create [EndDate] column.
EndDate = [StartDate]+[Duration]
2. Create a Measure.
Measure =
VAR t1 =
SELECTCOLUMNS (
'Table',
"Vendor_", 'Table'[Vendor],
"StartDate_", 'Table'[StartDate],
"EndDate_", 'Table'[EndDate]
)
VAR t2 =
FILTER (
CROSSJOIN ( 'Table', t1 ),
[Vendor] = [Vendor_]
&& NOT ( [EndDate] <= [EndDate_] )
)
VAR t3 =
ADDCOLUMNS (
t2,
"MinDate_", IF ( [StartDate] >= [StartDate_], [StartDate], [StartDate_] ),
"MaxDate", IF ( [EndDate] >= [EndDate_], [EndDate_], [EndDate] )
)
VAR t4 =
ADDCOLUMNS ( t3, "OverlapDay", DATEDIFF ( [MinDate_], [MaxDate], DAY ) )
VAR t5 =
ADDCOLUMNS (
t4,
"Count_", COUNTAX (
FILTER (
t4,
[Vendor] = EARLIER ( [Vendor] )
&& [StartDate] = EARLIER ( [StartDate] )
&& [OverlapDay] > 0
),
[Vendor]
)
)
RETURN
MAXX ( t5, [Count_] + 1 )
For more details, please check the attached PBIX file,
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can create end date
end Date = [Start Date]+7
and refer to this article that can help: https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
@klintala what is the logic to get task happening at the same time?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
98 | |
93 | |
78 | |
62 | |
56 |
User | Count |
---|---|
248 | |
124 | |
111 | |
78 | |
78 |