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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Date Filter with Months on X-Axis

Hi All,

 

we need to show Months i.e Jan, Feb till Dec on X-axis of line chart, Some measure on Y-Axis and Year in Legends.

 My data set look like below.
As you can see, we have data from last year onwards till today.

 

Date

Measure

01-Jan-2018

1000

02-Jan-2018

1000

So On Till

 

26-July-2019

1000

 

 

 

Now in the date filter, we have date range by default set to 01/01/2019 to today as per requirement.
In default case, it works fine, showing months on x-axis and legends for both years i.e 2018 and 2019.
When we apply filter in date slicer, say we select date range as 01-Mar-2019 to today,
it should show Months from March to July on x-axis with legends for both years to compare the data Month-on-Month data for both years. However, it erases the 2018 line as soon as we appy date range, shows only 2019 data.
In default case, it works perfectly fine. Please help us here.

 

2 REPLIES 2
parry2k
Super User
Super User

@Anonymous in this case you should have another measure for previous year and use both measure on values, and nothing on legend.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi @parry2k ,

 

Thank you so much for this response. Can you please let me know how to compute last year's measure value date filters applied. Currently i am using below formulas to compute Current and last year measures. Please find below the same.

 

HM_VALUE_CY = CALCULATE(SUM(GAEventData[Unique Events]), GAEventData[Date],
FILTER(GAEventData, AND((GAEventData[Event Category] = "Help Me Choose"),
(GAEventData[Event Action] = "completion"))), YEAR(GAEventData[Date]) = YEAR(TODAY()))
 
and 
HM_VALUE_LY = CALCULATE(SUM(GAEventData[Unique Events]), PARALLELPERIOD(GAEventData[Date], -1, YEAR),
FILTER(GAEventData, AND((GAEventData[Event Category] = "Help Me Choose"),
(GAEventData[Event Action] = "completion"))))
 
Now it's working for default filters which is 01/01/2019 to 07/29/2019 i.e today's date. If i change date range to say 07/08/2019 to 07/10/2019, it should display data for 07/08/2019 to 07/10/2019 in current year measure and 07/08/2018 to 07/10/2018 in last year's measure. Current year is filtering fine but last year is not filtering at all. I even tried using SAMEPERIODLASTYEAR function for last year measure function but it's not working. Please help me here.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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