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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Need to display rolling 6 months data in each month bar.

Hi There, I have learnt a lot from the community. Thanks for that first. This is my first post & I have a query.

I have a bar chart which displays each month total. [Count of users]
My date filters are from the same table (its a Date Range with slider).
I need to show rolling 6 months data in each month bar.
Eg. If i select a date range in the filter (01-01-2021 to 30-06-2021) the following is expected
June 2021 bar should display Jan 2021 to May 2021 aggreagate data , and
May 2021 data bar should display December 2020 to April 2021 show aggreagate data and so on.
Every month bar should have the previous 6 months data in it.

mannarmannans_0-1625158722748.png

I have tried writing a measure as follows

010 Moving Month = IFERROR(CALCULATE(DISTINCTCOUNTNOBLANK(Append2[USER_EMAIL]),DATESINPERIOD(Append2[Date(Key1)].[Date],LASTDATE(Append2[Date(Key1)].[Date]),-6,MONTH))+0,0)

When i add this measure to the column value it displays zero.
mannarmannans_1-1625158861054.png

If i display this measure in a card and use the date filter as dropdown and select particular month and year this displays the last 6 months values from June 2021

mannarmannans_2-1625159012681.png

Thanks in advance.

Note: I am a beginner 🙂





1 ACCEPTED SOLUTION
daxer-almighty
Solution Sage
Solution Sage

// First of all, a correct model in PBI
// NEVER uses the auto-generated date
// tables and date/time hierarchies. They
// are---simply put---wrong. That's the first thing.
// Second, in a good model, one where
// there's a proper Date table as outlined
// in, say, https://dax.guide/dateadd, you
// can write:

[User Count 6M-Sum] =
// Grab the last date visible in the
// current context
var LastVisibleDate = MAX( Dates[Date] )
// Create a new filter on Dates
// that spans a period of 6 months
// which ends on the LastVisibleDate.
var NewDateFilter =
    DATESINPERIOD(
        Dates[Date],
        LastVisibleDate,
        -6, MONTH
    )
var Result =
// Apply the new filter and remove
// all original filters from Dates.
    CALCULATE(
        [User Count],
        NewDateFilter,
        REMOVEFILTERS( Dates )
    )
return
    Result

View solution in original post

2 REPLIES 2
daxer-almighty
Solution Sage
Solution Sage

// First of all, a correct model in PBI
// NEVER uses the auto-generated date
// tables and date/time hierarchies. They
// are---simply put---wrong. That's the first thing.
// Second, in a good model, one where
// there's a proper Date table as outlined
// in, say, https://dax.guide/dateadd, you
// can write:

[User Count 6M-Sum] =
// Grab the last date visible in the
// current context
var LastVisibleDate = MAX( Dates[Date] )
// Create a new filter on Dates
// that spans a period of 6 months
// which ends on the LastVisibleDate.
var NewDateFilter =
    DATESINPERIOD(
        Dates[Date],
        LastVisibleDate,
        -6, MONTH
    )
var Result =
// Apply the new filter and remove
// all original filters from Dates.
    CALCULATE(
        [User Count],
        NewDateFilter,
        REMOVEFILTERS( Dates )
    )
return
    Result
Anonymous
Not applicable

Thank a lot. That worked prefectly. 🤗

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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