Forum Discussion
How to Adjust Service Measures Based on Date Range
- Anonymous2 years ago
Hi alanvicsansz ,
I've made a test for your reference:
1\Add two caculate column for Ocorrencias
Year = YEAR(Ocorrencias[data_ocorrencia])Month = MONTH(Ocorrencias[data_ocorrencia])2\Set these two measure
Ano atual = VAR MaxYear=YEAR(CALCULATE(MAX(Ocorrencias[data_ocorrencia]),ALLSELECTED(Ocorrencias))) Var MaxMonth= MONTH(CALCULATE(MAX(Ocorrencias[data_ocorrencia]),ALLSELECTED(Ocorrencias))) RETURN CALCULATE(COUNTROWS(ALLSELECTED(Ocorrencias)),Ocorrencias[Month]=SELECTEDVALUE(Calendario[MesNum]) && MaxYear=Ocorrencias[Year] && Ocorrencias[Month]<=MaxMonth )Ano anterior = VAR MaxYear=YEAR(CALCULATE(MAX(Ocorrencias[data_ocorrencia]),ALLSELECTED(Ocorrencias)))-1 Var MaxMonth= MONTH(CALCULATE(MAX(Ocorrencias[data_ocorrencia]),ALLSELECTED(Ocorrencias))) RETURN CALCULATE(COUNTROWS(ALLSELECTED(Ocorrencias)),Ocorrencias[Month]=SELECTEDVALUE(Calendario[MesNum]) && MaxYear=Ocorrencias[Year])Best Regards,
Bof
Hello alanvicsansz
To clarify your question further:
For the current year value, you seek the total values for the entire month corresponding to the latest selected date. For instance, if the latest selected date is February 22, 2023, the current year value would be the "sum of values for February 2023." I hope I have understood the logic for calculating the "Current Year" correctly.
Regarding the previous year, I did not fully grasp your requirements. Could you please rephrase and provide some examples to aid my understanding of the issue?
Additionally, it would be helpful if you could provide a snapshot of the "Expected Answer" or data to accompany the explanation of the "Previous Year" calculation logic.
Thank you,
Udit
- alanvicsansz2 years agoFrequent Visitor
Let me know if the screenshot helps. If you need more details, feel free to ask and I'll be happy to provide more info!