Forum Discussion
Distribute date ranges into groups automatically
- 5 years ago
Hi Anonymous ,
First create a column as below:
Rank = RANKX(FILTER('Table','Table'[Project #]=EARLIER('Table'[Project #])),'Table'[Dates worked],,ASC)Then create a measure as below:
Thirds = var _max=MAXX(FILTER(ALL('Table'),'Table'[Project #]=MAX('Table'[Project #])),'Table'[Rank]) var _count=CALCULATE(COUNT('Table'[Project #]),FILTER(ALL('Table'),'Table'[Project #]=MAX('Table'[Project #]))) Return IF(_max<=3,MAX('Table'[Rank]),DIVIDE(MAX('Table'[Rank]),_count/3))And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
Anonymous im sorry to say that did not work.
With a live example, this is the result of your formula
| Project # | Dates worked | |
| Project 1 | Friday, June 26, 2020 | 2 |
| Project 1 | Saturday, June 27, 2020 | 1 |
| Project 1 | Sunday, June 28, 2020 | 1 |
| Project 1 | Monday, June 29, 2020 | 1 |
| Project 1 | Tuesday, June 30, 2020 | 3 |
| Project 1 | Wednesday, July 1, 2020 | 1 |
| Project 1 | Thursday, July 2, 2020 | 1 |
| Project 1 | Friday, July 3, 2020 | 2 |
| Project 1 | Saturday, July 4, 2020 | 2 |
| Project 1 | Sunday, July 5, 2020 | 1 |
| Project 1 | Monday, July 6, 2020 | 3 |
| Project 1 | Tuesday, July 7, 2020 | 2 |
| Project 1 | Wednesday, July 8, 2020 | 3 |
| Project 1 | Thursday, July 9, 2020 | 1 |
| Project 1 | Friday, July 10, 2020 | 2 |
| Project 1 | Saturday, July 11, 2020 | 1 |
| Project 1 | Sunday, July 12, 2020 | 1 |
| Project 1 | Monday, July 13, 2020 | 1 |
| Project 1 | Tuesday, July 14, 2020 | 3 |
| Project 1 | Wednesday, July 15, 2020 | 1 |
| Project 1 | Thursday, July 16, 2020 | 1 |
| Project 1 | Friday, July 17, 2020 | 3 |
| Project 1 | Saturday, July 18, 2020 | 1 |
| Project 1 | Sunday, July 19, 2020 | 1 |
| Project 1 | Monday, July 20, 2020 | 1 |
| Project 1 | Tuesday, July 21, 2020 | 1 |
| Project 1 | Wednesday, July 22, 2020 | 3 |
| Project 1 | Thursday, July 23, 2020 | 3 |
| Project 1 | Friday, July 24, 2020 | 2 |
| Project 1 | Saturday, July 25, 2020 | 3 |
| Project 1 | Sunday, July 26, 2020 | 3 |
| Project 1 | Monday, July 27, 2020 | 3 |
the result im looking for is below
| Project # | Dates worked | |
| Project 1 | Friday, June 26, 2020 | 1 |
| Project 1 | Saturday, June 27, 2020 | 1 |
| Project 1 | Sunday, June 28, 2020 | 1 |
| Project 1 | Monday, June 29, 2020 | 1 |
| Project 1 | Tuesday, June 30, 2020 | 1 |
| Project 1 | Wednesday, July 1, 2020 | 1 |
| Project 1 | Thursday, July 2, 2020 | 1 |
| Project 1 | Friday, July 3, 2020 | 1 |
| Project 1 | Saturday, July 4, 2020 | 1 |
| Project 1 | Sunday, July 5, 2020 | 1 |
| Project 1 | Monday, July 6, 2020 | 1 |
| Project 1 | Tuesday, July 7, 2020 | 2 |
| Project 1 | Wednesday, July 8, 2020 | 2 |
| Project 1 | Thursday, July 9, 2020 | 2 |
| Project 1 | Friday, July 10, 2020 | 2 |
| Project 1 | Saturday, July 11, 2020 | 2 |
| Project 1 | Sunday, July 12, 2020 | 2 |
| Project 1 | Monday, July 13, 2020 | 2 |
| Project 1 | Tuesday, July 14, 2020 | 2 |
| Project 1 | Wednesday, July 15, 2020 | 2 |
| Project 1 | Thursday, July 16, 2020 | 2 |
| Project 1 | Friday, July 17, 2020 | 2 |
| Project 1 | Saturday, July 18, 2020 | 3 |
| Project 1 | Sunday, July 19, 2020 | 3 |
| Project 1 | Monday, July 20, 2020 | 3 |
| Project 1 | Tuesday, July 21, 2020 | 3 |
| Project 1 | Wednesday, July 22, 2020 | 3 |
| Project 1 | Thursday, July 23, 2020 | 3 |
| Project 1 | Friday, July 24, 2020 | 3 |
| Project 1 | Saturday, July 25, 2020 | 3 |
| Project 1 | Sunday, July 26, 2020 | 3 |
| Project 1 | Monday, July 27, 2020 | 3 |
Im trying to break the Projects duration into 3 parts... in chronological order. So in the case above, the first 11 dates would be "1", the middle "2", and the latter "3"
Hi Anonymous
_number =
var _cnt = rankx(allselected(Table1),CALCULATE ( MAX (Table1[Dates worked])),,ASC)
var _max = CALCULATE(COUNTROWS(Table1),ALLEXCEPT(table1,Table1[Project #]))
var _d3 = _max/3
return CEILING(_cnt/_d3,1)- Anonymous5 years agoNot applicable
Anonymous
So as a measure, it doesn't seem to stop at 3. I see values up into the hundreds.
because of the insight im looking to get, the best solution for this would be a calculated column..however when i add the formula in for my new column I get the error "A circular dependency was detected: Table1[Column]."
any thoughts?
- Anonymous5 years agoNot applicable
Hi Anonymous
According to your sample my previous reply answers your question.
Probably you should put more time in making a good sample of your data when ask so that you get to the point reply.
Try the below as a measure, column is preferred when there is a calculation done for each row.
_number = var _cnt = rankx(allselected(Table1),CALCULATE ( MAX (Table1[Dates worked]), allexcept(table1, table1[Project #])),,ASC) var _max = CALCULATE(COUNTROWS(Table1),ALLEXCEPT(table1,Table1[Project #])) var _d3 = _max/3 return CEILING(_cnt/_d3,1)- Anonymous5 years agoNot applicable
My apologies that my request was unclear. I don't use the forums often to request help, so forgive me for thinking I had explained what i was looking for thoroughly enough.
I have tried your measure, and its actually gotten worse in the number return.
I shall try to explain this more in depth.
The need: To break down a Projects duration (start to finish) into thirds. Identify which dates fall into which 3rd of each project. Durations can be anywhere from 1 day to hundreds of days long. We have a table with thousands of projects of varying durations. I have already created a table that shows the Project Number and each individual date the project was active. shown here
Example Table:
Project # Dates worked Project 1 7/4/2019 Project 1 7/5/2019 Project 1 7/6/2019 Project 1 7/7/2019 Project 1 7/8/2019 Project 1 7/9/2019 Project 2 8/10/2019 Project 2 8/11/2019 Project 3 5/4/2019 Project 3 5/5/2019 Project 3 5/6/2019 The request: Can anyone help me create a Calculated Column, either in DAX or in Power Query, to label each row as either the first, middle or latter third of a project. The result would look like below
Example Table 2: Desired Outcome
Project # Dates worked Thirds Project 1 7/4/2019 1 Project 1 7/5/2019 1 Project 1 7/6/2019 2 Project 1 7/7/2019 2 Project 1 7/8/2019 3 Project 1 7/9/2019 3 Project 2 8/10/2019 1 Project 2 8/11/2019 2 Project 3 5/4/2019 1 Project 3 5/5/2019 2 Project 3 5/6/2019 3 I hope this explanation is clearer than my original ask.