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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.