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, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
noircrk
Frequent Visitor

DAX Compare N number of days across Months

I have a date slicer that generally is used for MTD.  For example my slicer shows March 1st - March 20th and a have a single bar on a bar graph that shows the number of widgets sold for that time period.  What I need to add is the number of widgets sold Feb. 1st - Feb 20th as a bar, Jan1st- Jan20th as a bar and so on for the 12 previous months.

 

I would need this to change based on the selection of the slicer, so if I change it to Mar 1st - Mar 25th the other data points would adjust for 1st-25th in their respective months.

 

How would I go about accomplishing this???  Any and all suggestions are welcome.

1 ACCEPTED SOLUTION
noircrk
Frequent Visitor

I have solved my problem using the below video by @parry2k :

 

https://www.youtube.com/watch?v=UG1WxkBkM48

 

This solution worked perfectly for my need.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@noircrk glad to hear that my youtube video helped to solve your problem. Thanks!



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.

noircrk
Frequent Visitor

I have solved my problem using the below video by @parry2k :

 

https://www.youtube.com/watch?v=UG1WxkBkM48

 

This solution worked perfectly for my need.

wdx223_Daniel
Super User
Super User

MTD = VAR _year=2008 VAR _month=3 VAR _day=31 RETURN CALCULATE(TOTALMTD([Sales Amount],'Date'[Date]),FILTER('Date','Date'[Month Number]<=_month&&DAY('Date'[Date])<=_day&&'Date'[Calendar Year Number]=_year))

Thank you @wdx223_Daniel !  Could you help me understand what it is this formula does?  Variables for Year, Month and Day I wouldn't think would be hardcoded with values and I don't see any mentions of getting the prior months data.

 

When I adapt this to my data the result is empty.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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