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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

MAX of measure calculation

Hi guys,

 

Here I am again trying to find some helpfull tips on a problem that been causing me headaches for a while now.

I'm using Alberto Ferrari's "12 months back" calculation, with the previous period calendar to return measures for previous 12 month based on slicer selection (measure inclosed bellow).

I now need to calculate the MAX of a measure for those 12 period that are in scope, but for some reason I get the value only for the last period selected (MAX of external period slicer), when instead I need the MAX within those 10 periods in scope (in my example that's P9 = 9.37e) :

Wildrosezuzi_1-1675176730217.png

 

The problem is that calculatetable seems to be returning only the MAX peirod in selection, instead of MAX of the measure. 

 

I hope you can fix my code. I want my normal sleep cycle back 😄

 

Top Limit =
VAR NumOfMonths = 12

VAR ReferenceDate =
    MAX ( 'Date Table'[CalendarDate] )
VAR PreviousDate =
    DATESINPERIOD (
        'Previous Date'[CalendarDate],
        ReferenceDate,
        - NumOfMonths,
        MONTH
    )

Var Result =
MAXX(
    CALCULATETABLE('Sell Out Data',
       REMOVEFILTERS ( 'Date Table' ),
        KEEPFILTERS ( PreviousDate ),
        USERELATIONSHIP ( 'Date Table'[CalendarDate], 'Previous Date'[CalendarDate] )),
   (SUM('Sell Out Data'[BaseValue]) / ((AVERAGE('Sell Out Data'[WeightedDistWeek])/100)* MAX('Sell Out Data'[storesinuniverse]))/4))

Return
Result

 

1 REPLY 1
Anonymous
Not applicable

Is this that difficult to achieve in Power BI? 😅

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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