Forum Discussion
Calc Column marking earliest dates
Hello,
Just started using DAX, powerpivot, and power BI and loving it. I'm trying to make a Calc Column for the earliest project date for each of our agents (sample data below). I imagine it looks something like SWITCH(TRUE,AND([Date of Project]=??,[agent code]=??),"FIRST PROJECT","") that goes into the flag column.
but any help would be cool 🙂
| AgentCode | ProjectDate | ProjectName | FLAG? |
| 123456 | 6/4/2019 | Project 212 | |
| 123456 | 3/1/2020 | Project 564 | |
| 123456 | 9/23/2020 | Project 951 | |
| 234567 | 9/2/2020 | Project 367 | |
| 456789 | 12/7/2019 | Project 852 | |
| 456789 | 3/9/2020 | Project 264 |
You should probably do this as a measure instead but it is common for people new to Power BI to overuse calculated columns. Here is a column expression to get your result, but it would work as a measure too (in a table visual with the AgentCode column).
First Project Date = CALCULATE(MIN(Table[ProjectDate]), ALLEXCEPT(Table, Table[AgentCode]))
Regards,
Pat
1 Reply
- mahoneypatMicrosoft Employee
You should probably do this as a measure instead but it is common for people new to Power BI to overuse calculated columns. Here is a column expression to get your result, but it would work as a measure too (in a table visual with the AgentCode column).
First Project Date = CALCULATE(MIN(Table[ProjectDate]), ALLEXCEPT(Table, Table[AgentCode]))
Regards,
Pat