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
hansolo
Helper I
Helper I

IsInThisMonth,Quarter,Year ... IsInPrevious Month, Quart, Year

I used a great solution from elliotdixon as described below to build slicers based on week to date, current week and last week ..

 

http://community.powerbi.com/t5/Desktop/Display-this-week-amp-this-month-data/td-p/11101

 

I want to do the same for current/previous year, current/previous month and current/previous quarter but I Icant seem to extend his knowledge to those fields.

 

Does anyone have an example of this they would be willing to share?

 

Thank you, 

 

Dave

1 ACCEPTED SOLUTION

Please read this article - it should give you exactly what you want

/sdjensen

View solution in original post

9 REPLIES 9
hansolo
Helper I
Helper I

*bump* while i appreciate the help from the last two users I really didnt get what I was looking for ... To clue you in, I am trying to create something like the picture below, where the user has the ability to simply press a button and pare down selections to WTD, Last Week, Last 7 Days, Current Week ... I just need to fill in the gaps for Current Month, Previous Month, Current Quarter, Previous Quarter ... I feel like someone had to do this before so I am hoping I can leverage without reinventing the wheel.

 

Thanks,

 

Dave 

 

 

 

 

Capture.PNG

Please read this article - it should give you exactly what you want

/sdjensen

 

@hansolo - the code he uses is M is the code created by and used by the Query Editor (Power Query). Chris is the master of all masters of M and he literally wrote the book about it. In the end of the article there is a link to a test file.

 

Go to the query editor and add a new blank query and then go to advanced editor on this new blank query here you can write the M code yourself.

 

If you need help with M functions you can go to this page.

/sdjensen

@sdjensen thank you again. very helpful. 

samdthompson
Memorable Member
Memorable Member

@hansolo hey if solved can you mark and such? Thanks mate.

// if this is a solution please mark as such. Kudos always appreciated.

@samdthompson just need a second to plug it in before I mark a solution. wanted to give you kudos either way

samdthompson
Memorable Member
Memorable Member

I use a slightly different approach to get the answer. In the calendar table I create a dynamic column which is

 

if(now()=dim_date[calendar_date],"today",if(date(year(now())-1,,month(now)),day(now())),"today last year",""). When you use it grab say calendar week from the date table, the measure and use new column as your slicer.

 

play round a bit to get current week or last week etc.

 

note I use the date with year()-1 as i ofen work with 366 day years.

// if this is a solution please mark as such. Kudos always appreciated.

When I do this I create some Dynamic Year/Quarter/Month columns in my period table that will give me the option to dynamically filter x eg. years back in time.

 

Try to read my answer here. I give the code on how I create a dynamic month slicer.

/sdjensen

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.

Top Solution Authors