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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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