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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hudsonvj
Frequent Visitor

Soma acumulada do ano anterior , mesma quantidade de dias do período atual

Boa tarde. Preciso efetuar uma soma acumulada comparando a quantidade de dias do ano atual com a quantidade de dias do ano anterior, considerando aplicação de filtro do ano e mês quando necessário.

 

Ex : No meu ano atual até 30/06/2022 eu tenho 58 dias.  Que no caso se inicia em 04/05/22 e vai até 30/06/2022. 
O que quero é efetuar uma soma acumulada do ano anterior que seja igual a quantidade de dias do ano atual e do mês selecionado, no caso os 58 dias até 30/06/22. No caso o intervalo de datas do ano anterior que íra dar os 58 dias igual do ano atual é de 09/04/2021 até 05/06/2021 , que dá 58 dias. O valor de resultado quando selecionado o ano de 2022 e mes de junho deve dar 396.299 . Como os periodos ( datas ) não são iguais então não esta dando certo.

BI.png

Acredito que apenas funções de inteligencia temporal sozinhas não irão atender.

 

Abaixo tenho o modelo usado atualmente no excel. Onde os valores correspondem aos 58 dias, do ano atual e ano anterior.

Sem título.png 

 

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

Hi @hudsonvj ,

 

Sorry for that the information you have provided is not making the problem clear to me. How the previous year's date is calculated? Is it based on the same end month or the total number of days?

 

Please provide me with more details about your data and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

1. Have a calendar table in your data model and mark it as a Date table.  Do not use Auto Date/Time.

2. Refresh this table daily in Import Mode

3. Add a calculated column that tags prior periods (month, quarter, year) if they are past the current date or not  (use TODAY() or - more appropriately - the maximum transaction date of the current period)

4. Include that calculated column as a filter in your calculations.  For example (pseudo code):

Previous Year To Date = CALCULATE([Sales],SAMEPERIODLASTYEAR(<date from calendar here>,IsPastPY = True())

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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