Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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)
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
)
)
@tahechadv_2022 Can you provide a sample/example of your raw data?
Without comprimise data protection, not too much
@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
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
)
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
57 | |
38 | |
36 |
User | Count |
---|---|
81 | |
67 | |
62 | |
46 | |
45 |