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
iDataDrew
Advocate IV
Advocate IV

Rolling 3 mos when spans end of previous yr and beginning of current yr; sorting issue as well

I don't have sample data to share, but any possible solutions based on your past experience would be appreciated.

 

I have to write a rolling 3 month sum measure, but I have to keep in mind that on January of the current year (for example) it will have to show November and December of the previous year.  I think the following filtering would work:

 

DATESINPERIOD ( table[date], TODAY(), -3, MONTH)

 

However, I think the problem I'm running into is that the x-axis is the end of week (week-based).  I created this end of week columns as follows:

 

EndOfWeek = FORMAT(DimDate[Date]+(6-WEEKDAY(DimDate[Date])),"MMM-DD")

 

But I can't seem to properly sort this column by the Date column due to the error that there can't be more than one value in the Date column for the same value in the EndOfWeek column.  So maybe this is more of a sorting question for this kind of column.

1 ACCEPTED SOLUTION

@Phil_Seamark I got the same error.  This is because the way I have the FORMAT() make the EndOfWeek dates show as month and day, which means there are duplicate values in the column (one for each year).  I just took away the FORMAT() from the EndOfWeek column so that it displays as a regular date, which means there will be distinct values.  This solves the sorting issue.  Then I just selected the date formatting option from the menu bar to display as MMMM DD.

View solution in original post

2 REPLIES 2
Phil_Seamark
Employee
Employee

Hi there

Please try creating the following extra column to us as a sorting col.


EndOfWeekID = INT (FORMAT(DimDate[Date]+(6-WEEKDAY(DimDate[Date])),"YYMMDD"))

And use this as your sort by column for your EndOfWeek

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

@Phil_Seamark I got the same error.  This is because the way I have the FORMAT() make the EndOfWeek dates show as month and day, which means there are duplicate values in the column (one for each year).  I just took away the FORMAT() from the EndOfWeek column so that it displays as a regular date, which means there will be distinct values.  This solves the sorting issue.  Then I just selected the date formatting option from the menu bar to display as MMMM DD.

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.