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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
JackWren
Helper I
Helper I

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak  Thank you so much! 

 

It works perfectly well 🙂 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Top Kudoed Authors