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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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

Share with Power BI Enthusiasts: 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])

Share with Power BI Enthusiasts: 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.