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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
tahechadv_2022
Helper II
Helper II

How to fill empty values from with values from previous month?

Hi guys,

I need to fill the current month value with the previous month value without altering the total. Here's the example:
(Due to privacy of our finances data, it was required censor the data)

tahechadv_2022_0-1691413138981.png

 

I need to take the value from "Julho" (July) and fill and "Agosto" (August) with these value WITHOUT altering the "Total" and it needs to be dynamic, in other words, the dax needs to take the values of the previous month, and IF the curent month is empty, it would replace it.

 

* the column with dates is called "data_lancamento"


The dax:

Acumulado Banco = 

VAR Banco = VALUES('Capital de Giro'[banco])
VAR IDGeral = MAX('Capital de Giro'[ID Geral])

RETURN
CALCULATE(
    SUM('Capital de Giro'[valor]),
        FILTER(
            ALL('Capital de Giro'),
            'Capital de Giro'[ID Geral] <= IDGeral &&
            'Capital de Giro'[banco] IN Banco
        )
)
4 REPLIES 4
Greg_Deckler
Super User
Super User

@tahechadv_2022 Can you provide a sample/example of your raw data?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Without comprimise data protection, not too much

tahechadv_2022_0-1691416253337.png

 

@tahechadv_2022 Well, if you use Fill down in Power Query that is going to affect your total. You could do this in a measure although you will almost certainly encounter a measure total issue (maybe not). Basically in the measure, you could get the sum, VAR __Sum = SUM('Table'[condigo]). If it is BLANK, IF(__Sum = BLANK(), <previous row's value>, __Sum). You shoudl be able to get the previous row's value via some fancy filtering. See MTBF for an example.

See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I understood the concept, but a doubt remained:
How would I apply the concept to my dax:

The new dax:

Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous

My dax:

Acumulado Banco = 

VAR Banco = VALUES('Capital de Giro'[banco])
VAR IDGeral = MAX('Capital de Giro'[ID Geral])

RETURN
CALCULATE(
    SUM('Capital de Giro'[valor]),
        FILTER(
            ALL('Capital de Giro'),
            'Capital de Giro'[ID Geral] <= IDGeral &&
            'Capital de Giro'[banco] IN Banco
        )
)

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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