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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
christianfcbmx
Post Patron
Post Patron

DAX IDEAS PLEASE

Dear Colleagues Im not getting so smart today and I need your help:

 

Im trying the following: I need to create a chart out of my data always getting the last 5 or 4 weeks (Axis Y quantities, axis X week number) (Hopefully with an option to choose how many weeks you want to show). the next step is to create 1 chart for each week of the last 5 or 4 week chosen of my first chart (First chart week 1, second chart week 2 and so on).

 

 

Im not that good at DAXING in power BI yet and Ive spent hours trying to figure something out with no results...Anyone have an idea or a dax already done to share?

 

sample files: https://www.dropbox.com/s/f99yqz9my1nyjx6/Counting%20weeks%202.pbix?dl=0

 

Thank you guys in advance!!!

 

11 REPLIES 11
Ashish_Mathur
Super User
Super User

Hi,

 

I think i can help you with answering the first question.  Share some data and show your expected result there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur... look what I did with the months is what I need with the weeks (I was thinking about an index column) tell me what you think....thanks in advance!

 

https://www.dropbox.com/s/f99yqz9my1nyjx6/Counting%20weeks%202.pbix?dl=0

 

Hi,

 

You have to use the CALCULATE, COUNT and DATESBETWEEN functions in a measure.  Somehow when i try it, i get a syntax error and cannot figure out why i get that error.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mbenjamin
Kudo Collector
Kudo Collector

@christianfcbmx

 

This doesn't solve your immediate problem, but I thought you might be interested in this upcoming webinar about Practical DAX.

 

It's airing April 3rd. 🙂

 

do you know the ending time of the webinar? lenght?

@christianfcbmx Apologies for the late response! The webinar is available on demand and is approximately 60 minutes long. 

Thanks for that information, It sounds awesome and Ill be there! Thank you again @mbenjamin

ChrisMendoza
Resident Rockstar
Resident Rockstar

Hello @christianfcbmx

 

Possibly a Relative Slicer is part of the solution? Using the [Date] from 'dCalendar'.

 

Click the little Down caret

Capture4.png

 

Select Relative

Capture1.png

 

Select the Drop-Down caret

Capture2.png

 

Select the built-in filter criteria

Capture3.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Hi @ChrisMendoza, I didnt realize that one... eventhough I was playing with "relative date filtering" in the visual and it work for months no for weeks... and to make it work correctly for months I made a DAX... any native power BI feature for what I was looking for worked properly without getting smart and add a DAX to make it work... the native solution you share doesnt work 100%... I chose the last 4 weeks and it shows 2... take a look at my pbix. and play... my DAX for month could be usefull for you (keep it) and tell me what you think 🙂

@christianfcbmx

 

I agree, the pre-built Relative Slicer is not 100% because your fact table has not been updated since March 1, 2018. Last 4 weeks (calendar) from today is March 3, 2018; therefore 'no data' is displayed. The same is said for Last 4 Weeks from today is March 6, 2018.

 

Seems your solution is something along the lines of Find the last date in the fact table, do some math to find the last x weeks, then do some more math (e.g. sum) based off the x results.

 

I think @Ashish_Mathur's comment is probably the direction you need to head.






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Still work it on it with no results...If I figure something out Ill let you guys know , @ChrisMendoza@Ashish_Mathur

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors