Forum Discussion
How to Automatically Move Unfinished Projects to the Next Month in Power BI
In Power BI, I have a table that counts the number of projects that need to be completed by their due date. However, there is a need for projects that are not completed within the specified month to automatically move to the next month. For example, a project scheduled for January, if not completed by the due date, should automatically move to February, and so on, until I update it in my data source. Is there a way to do this in Power BI?
- Anonymous1 year ago
Hi amaral_diego ,
I update the measure, you can try this one.
AjustarData = VAR _Today = TODAY () VAR _DATEDIFF = DATEDIFF ( 'Table'[Termino], TODAY (), DAY ) VAR _DATE1 = EOMONTH ( TODAY (), -1 ) + DAY ( 'Table'[Termino] ) VAR _DATE2 = EOMONTH ( _DATE1, 0 ) + DAY ( 'Table'[Termino] ) RETURN IF ( 'Table'[Status] = "Complete", 'Table'[Termino], IF ( 'Table'[Termino] < _Today, IF ( _DATE1 < TODAY (), _DATE2, _DATE1 ), 'Table'[Termino] ) )Result of my sample is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
12 Replies
- Kaviraj11Solution Sage
Hi,
Here’s a general approach to get you started
-
Add a Status Column: Ensure your data source has a column indicating whether a project is completed or not.
-
Create a Calculated Column
Here’s an example:
AdjustedDueDate = IF( [Status] = "Completed", [DueDate], EOMONTH([DueDate], 1) + 1 )3. Create a Measure for Counting Projects
Here’s an example measure:
ProjectsDueThisMonth = CALCULATE( COUNTROWS(ProjectsTable), FILTER( ProjectsTable, YEAR([AdjustedDueDate]) = YEAR(TODAY()) && MONTH([AdjustedDueDate]) = MONTH(TODAY()) ) )
- amaral_diegoHelper II
I've tried this way below
Created this Calculated Column
DataAjustada =
VAR DataInicial = f_Projetos[Termino]
VAR MesesAdicionados = DATEDIFF(DataInicial, TODAY(), MONTH) + 1
RETURN
IF(
DataInicial < TODAY(),
EDATE(DataInicial, MesesAdicionados),
DataInicial
)and this measure below
ProjetosAtrasadosPorMes =
CALCULATE(
COUNTROWS(
FILTER(
f_Projetos,
f_Projetos[Termino] < TODAY() &&
f_Projetos[Status] <> "Completo" &&
f_Projetos[Status] <> "Despriorizado" &&
f_Projetos[DataAjustada] >= EDATE(f_Projetos[Termino], 1)
)
),
USERELATIONSHIP(d_Calendario[Date], f_Projetos[DataAjustada])
)
It's almost working, the thing is, it showing the information on November column,
In my case, it should appear in October. It should move the overdue project to the following month, and here in my case the overdue projects are from September.
Could help me to solve this- Kaviraj11Solution Sage
Can you update with this
Here’s a revised version of your calculated column:
DataAjustada = VAR DataInicial = f_Projetos[Termino] VAR MesesAdicionados = DATEDIFF(DataInicial, TODAY(), MONTH) + 1 RETURN IF( DataInicial < TODAY(), EOMONTH(DataInicial, MesesAdicionados - 1) + 1, DataInicial )
-
- lbendlinSuper User
Remember that MAX( ) can take two parameters, not just one.
- amaral_diegoHelper II
I also have tried with M language, with this function below
(AjustarData as nullable date) as nullable date =>
let
DataAtual = DateTime.LocalNow(),
NovaData = if AjustarData <> null and AjustarData < DataAtual then Date.AddMonths(AjustarData, 1) else AjustarData
in
NovaData
Then I go to "add column" and then "Invoke Custom Function"
So I select the function I created and then it gives me the option to enter a date, or select a column. If I go by the column or select the column that has the end date "Termino", it creates the column but without being in the date format and with "Error" in all the lines. This is the code that is in the column.
= Table.AddColumn(#"Erros Substituídos", "Nova Data - Conclusão", each fnAjustarDataConclusao([Termino]))
Is there any way to adjust this, so that it creates the dates for the following month automatically?- AnonymousNot applicable
Hi amaral_diego ,
Are you trying to delay the end date of a project whose due status is not yet Complete by one month?
Please try code as below to create a calculated column.
AjustarData = VAR _DATEDIFF = DATEDIFF('Table'[Termino],TODAY(),Day) RETURN IF('Table'[Status] = "Complete",'Table'[Termino],IF('Table'[Termino]<TODAY(),EOMONTH(TODAY(),-1)+DAY('Table'[Termino]),'Table'[Termino]))Result of my sample is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- amaral_diegoHelper II
Hi, with this code is almost helped me, it worked to send all projects to the next moth, but, for example, now I've 6 projects delayed from september that is now send to october, although I've one deleyed in october and he still in octorber, is possible to sent him do november?
If not, it's ok, I'll acept thi one as solution, thanks a lot.