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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JackWren
Helper II
Helper II

Moving Difference - 1st selected month should be 0

Hi everyone, 

 

I have recently created different measures to see the evolution of my data month by month and to have the line value that shows the difference in evolution between selected months. 

 

1/ Evolution 

 

Evolution =
AVERAGEX (
VALUES ( 'DWH Calender'[DATES] ),
VAR EndofMonth1 = max('DWH Calender'[MONTH_END_DT])
VAR BeforeStartdate =
FILTER (
ALL ( 'SplitPlan Table'[ASSIGN_START_DT]),
'SplitPlan Table'[ASSIGN_START_DT] <= EndofMonth1
)
VAR AfterEnddate =
FILTER (
ALL('SplitPlan Table'[ASSIGN_END_DT] ),
'SplitPlan Table'[ASSIGN_END_DT]>= EndofMonth1
)
RETURN
CALCULATE (
DISTINCTCOUNT('SplitPlan Table'[NA]),
BeforeStartdate,
AfterEnddate,
ALL( 'DWH Calender' )
)
)

 

The measures for the line chart

 

A/ Evolution Previous Period 

 

EvolutionPreviousPeriod =
Var Interval = calculate(
datediff(
max('DWH Calender'[DATES]),
min('DWH Calender'[DATES]),MONTH
),
ALLSELECTED('DWH Calender'[MONTHS])
)

RETURN

CALCULATE(
[Evolution],
PARALLELPERIOD('DWH Calender'[DATES],-2,MONTH)
)

 

B/ Difference between  months to have the line chart

 

calculate([Evolution]-[EvolutionPreviousPeriod])

 

I have two problem 

 

1 - I wish to make the interval for EvolutionPreviousPeriod dynamic

But this measure returns 0 in the visual even though when I check the variable in itself the result is correct. 

 

EvolutionPreviousPeriod =
Var Interval = calculate(
datediff(
max('DWH Calender'[DATES]),
min('DWH Calender'[DATES]),MONTH
),
ALLSELECTED('DWH Calender'[DATES])
)

RETURN

CALCULATE(
[Evolution],
PARALLELPERIOD('DWH Calender'[DATES],Interval,MONTH)
)

 

 

2- My colleague have asked me to display 0 for the first month instead of the actual difference with the previous month. 

Like this 

 

JackWren_1-1633523447037.png

 

Has anyone ever encountered something like that? 

 

Thank you 

 

Jack

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@JackWren , Try measure like

 


Measure =
Var _min = minx(allselected('DWH Calender'),'DWH Calender'[DATES])
var _month = minx(filter(allselected('DWH Calender') , 'DWH Calender'[DATES] =_min),'DWH Calender'[Year Month])
return
if(max('DWH Calender'[Year Month]) =_month, blank(), [EvolutionPreviousPeriod])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

@amitchandak  Thank you so much! 

 

It works perfectly well 🙂 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@JackWren , Try measure like

 


Measure =
Var _min = minx(allselected('DWH Calender'),'DWH Calender'[DATES])
var _month = minx(filter(allselected('DWH Calender') , 'DWH Calender'[DATES] =_min),'DWH Calender'[Year Month])
return
if(max('DWH Calender'[Year Month]) =_month, blank(), [EvolutionPreviousPeriod])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  Thank you so much! 

 

It works perfectly well 🙂 

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.