Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
alanvicsansz
Frequent Visitor

How to Adjust Service Measures Based on Date Range

Hello everyone, good evening! I hope you are all doing well.

I would like to share the challenge I am currently facing regarding the performance measures of the customer service team.

 

Context of the Challenge

Currently, I have three measures that need adjustment:

  1. Current Year: Represents the number of calls handled in the current year filter.
  2. Previous Year: Represents the number of calls handled in the previous year filter.
  3. Total Accumulated: This is the sum of the current year and previous year measures.

 

Objective

The main objective is to ensure that these measures display values only when the specified date period is met.

 

Rules for Each Measure:

  1. Current Year:
    • If the maximum filtered date is, for example, January 31, 2023, the displayed value should only be for January 2023.
  2. Previous Year:
    • If the minimum filtered date is January 1, 2022, and the maximum date is January 31, 2023, all months should display values, restricting to indicate only the calls from the year 2022.
  3. Total Accumulated:
    • This measure will be the sum of the calls recorded in the current year and previous year measures.

 

Final Considerations

It is essential that the implementation of these rules ensures that the displayed values are consistent with the defined date range. If anyone has suggestions or ideas on how to approach this issue, I would appreciate any help. 💪

Photo:

Captura de tela 2024-10-08 011929.png

Download link -> Base de testes.pbix - Google Drive

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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])

vbofengmsft_0-1728463859363.png

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])

vbofengmsft_1-1728463925358.png

 

Best Regards,

Bof

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

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])

vbofengmsft_0-1728463859363.png

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])

vbofengmsft_1-1728463925358.png

 

Best Regards,

Bof

 

 

It worked perfectly, this was the result I was looking for, thank you very much. 💪🤝

quantumudit
Super User
Super User

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

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!

Teste.png

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors