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
dstarrynight
Frequent Visitor

User MEDIAN of rolling 7 day total

I'm trying to calculate the median of the all user's total over the last 7 days. The data is structured on a daily basis and each user can have mutliple amounts in a given day. I would like to SUM each user's total over a rolling 7 day period and then find the median amount of the total. I'm using MEDIANX and SUMMARIZE which will calculate the MEDIAN correctly if used in a card, but when I try to use the measure in a table, it's only calculating the median for a single day. Below are my formulas. 

 

User Total = SUM(Users[Amount])

 

User Total L7d =
     CALCULATE(
     [User Total],
     DATESINPERIOD ( Users[Date], LASTDATE(Users[Date]), -7, DAY )
)

 

Median Total L7d =
    MEDIANX (
          SUMMARIZE (
                    Users,
                    Users[UserID],
                    "Median Total L7d", Users[Users Total L7d]
          ),
          [Median Total L7d]
)

 

The formula "User Total L7d" is calculating the rolling sum correctly in the table, but when I add the "Median Total L7d" to the table (by date) it only calculates the median for that day. Sorry I can't post any screenshots, the data is confidential. Please let me know if anything is confusing and I can provide more detail. 

1 ACCEPTED SOLUTION

Hi,

 

Try this measure

 

Median Total L7d (Ashish) = MEDIANX(CALCULATETABLE(SUMMARIZE(VALUES(Users[UserID]),[UserID],"Median Total L7d",[User Total L7d]),DATESBETWEEN(Users[Date],MAX(Users[Date])-7,MAX(Users[Date]))),[Median Total L7d])

 

Hope this helps.


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

View solution in original post

11 REPLIES 11

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