Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hey guys, i have been struggling with this problem for a little while so hopefully someone here can help me. I havent been using power BI alot so maybe the anwser i quite ovious, however thanks for any input.
I have a dataset containing activity ID, start date and end date. My goal is to find out if the same activity happens several times in the same timeframe. My datasett looks like this:
Activity ID | Start date | End date | ||
100 | 01.01.2020 | 02.01.2020 | ||
200 | 04.01.2020 | 06.01.2020 | ||
200 | 05.01.2020 | 06.01.2020 | ||
300 | 10.01.2020 | 14.01.2020 | ||
200 | 15.01.2020 | 20.01.2020 | ||
100 | 20.01.2020 | 25.01.2020 | ||
300 | 26.01.2020 | 28.01.2020 |
As you can see activity 200 happens two times in the same periode (5. - 6. of januar, row 2 and 3). A possible solution would be to use DAX and make a calculated collum which returs the number of occurances.
The resultat would for example look like this:
Activity ID | Start date | End date | Occurances | |||
100 | 01.01.2020 | 02.01.2020 | 1 | |||
200 | 04.01.2020 | 06.01.2020 | 2 | |||
200 | 05.01.2020 | 06.01.2020 | 2 | |||
300 | 10.01.2020 | 14.01.2020 | 1 | |||
200 | 15.01.2020 | 20.01.2020 | 1 | |||
100 | 20.01.2020 | 25.01.2020 | 1 | |||
300 | 26.01.2020 | 28.01.2020 | 1 |
However this is just a solution, if you have a better one, feel free to share 🙂
Once again, thanks for any input.
Kind regards.
@Anonymous , Try a new column like
countx(filter(Table, [Activity ID] = earlier([Activity ID]) && [End date] >=earlier([start date]) && [End date] <=earlier([End date])),[Activity ID] )
HI @Anonymous ,
Not very clear.
Try creating a Calculated Column
Occ = COUNTROWS(FILTER('Table','Table'[Activity ID] = EARLIER('Table'[Activity ID]) && 'Table'[End date] = EARLIER('Table'[End date])))
Regards,
Harsh Nathani
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Thank you!
User | Count |
---|---|
21 | |
20 | |
13 | |
10 | |
8 |
User | Count |
---|---|
30 | |
28 | |
13 | |
12 | |
11 |