cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VSchepens Regular Visitor
Regular Visitor

YTD graph until selected month

Hi,

 

I could really use your help with the following measure.

 

I made a graph showing the total sales up to the selected month.

So if I select Dec 2018, I see jan -  dec 2018.

If I select jan 2019, I see only jan 2019.

 

2019-01-16_15-28-31.png

 

I used the following formula:

 

Turnover MSCI FY =
VAR MinDate = DATE(YEAR( MAX('Date'[Date]));1;1)
VAR MaxDate = MAX('Date'[Date])
RETURN CALCULATE([Total Turnover MSCI];FILTER(ALL('Date'[Date]);'Date'[Date] >= MinDate && 'Date'[Date] <= MaxDate))

 

The slicer is based on Date[Date], the axis is based on Billing[Date]. But both are linked.

 

Now I would like to add a YTD line in this graph or in another graph if this is easier.

The import thing is that 'Current Year' depends on the selected month.

If jan 2019 is selected, then Current Year is 2019. If Dec 2018 is selected, Current Year is 2018.

 

Really appreciate your help!

 

Valérie

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator v-yuezhe-msft
Moderator

Re: YTD graph until selected month

@VSchepens,

Please create a new date table using dax below. Please note that there is no relationship between the new date table and other table.

Calendar = CALENDARAUTO()

 

Then create the following measures in your table.

YTD = TOTALYTD([Total Turnover MSCI];'Date'[Date])
NewMeasure= var Ldate = MAX('Calendar'[Date])//Last date

return

         if(min('Date'[Date])<=Ldate;
                   [YTD])


At last, use date field of the new date table('Calendar'[Date]) to create slicer, create a line chart using 'Date'[Date] field and NewMeasure.

Regards,
Lydia

 

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 REPLY 1
Highlighted
Moderator v-yuezhe-msft
Moderator

Re: YTD graph until selected month

@VSchepens,

Please create a new date table using dax below. Please note that there is no relationship between the new date table and other table.

Calendar = CALENDARAUTO()

 

Then create the following measures in your table.

YTD = TOTALYTD([Total Turnover MSCI];'Date'[Date])
NewMeasure= var Ldate = MAX('Calendar'[Date])//Last date

return

         if(min('Date'[Date])<=Ldate;
                   [YTD])


At last, use date field of the new date table('Calendar'[Date]) to create slicer, create a line chart using 'Date'[Date] field and NewMeasure.

Regards,
Lydia

 

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Community Highlights

Community Highlights

Find out what's new in the Power BI Community!

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 293 members 3,294 guests
Please welcome our newest community members: