Forum Discussion
noob123newbie
2 years agoFrequent Visitor
Custom Trend Line on Bar Chart
Hi guys, I have this Dashboard that i am working on, i am looking to draw this trend line where I need to show a 20% increase from the previous month. E.g. Aug 2023 - 72 Sep 2023 - 1...
- Anonymous2 years ago
Hi noob123newbie ,
You can update the formula of measure [Trendline] as below, please find the details in the attachment.
Trendline = VAR _curmonth = SELECTEDVALUE ( 'Sales'[Month].[MonthNo] ) VAR _curyear = SELECTEDVALUE ( 'Sales'[Month].[Year] ) VAR _date = EOMONTH ( DATE ( _curyear, _curmonth, 1 ), -1 ) VAR PreviousMonthSum = CALCULATE ( SUM ( 'Sales'[Value] ), FILTER ( ALLSELECTED ( 'Sales' ), YEAR ( 'Sales'[Month] ) = YEAR ( _date ) && MONTH ( 'Sales'[Date] ) = MONTH ( _date ) ) ) RETURN IF ( ISBLANK ( PreviousMonthSum ), BLANK (), PreviousMonthSum * 1.2 )Best Regards
noob123newbie
2 years agoFrequent Visitor
Hi there,
i tried using the following DAX formula but not getting the desire result.
Trendline =
VAR PreviousMonthSum = CALCULATE(
SUM('Sales'[Value]),
DATEADD('Sales'[Date], -1, MONTH)
)
RETURN
IF(
ISBLANK(PreviousMonthSum),
BLANK(),
PreviousMonthSum * 1.2
)
Anonymous
2 years agoNot applicable
Hi noob123newbie ,
You can update the formula of measure [Trendline] as below, please find the details in the attachment.
Trendline =
VAR _curmonth =
SELECTEDVALUE ( 'Sales'[Month].[MonthNo] )
VAR _curyear =
SELECTEDVALUE ( 'Sales'[Month].[Year] )
VAR _date =
EOMONTH ( DATE ( _curyear, _curmonth, 1 ), -1 )
VAR PreviousMonthSum =
CALCULATE (
SUM ( 'Sales'[Value] ),
FILTER (
ALLSELECTED ( 'Sales' ),
YEAR ( 'Sales'[Month] ) = YEAR ( _date )
&& MONTH ( 'Sales'[Date] ) = MONTH ( _date )
)
)
RETURN
IF ( ISBLANK ( PreviousMonthSum ), BLANK (), PreviousMonthSum * 1.2 )
Best Regards