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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
JamesBurke
Helper III
Helper III

Max Month usages

Hi All , 

Max Month Usages = 
Var MaxMonthValue = 
CALCULATE(
    MAX('Date'[Year Month Number]) ,
    FILTER('Date',[UsagesCount] >= 1),
    ALL('Date'))
    RETURN 
CALCULATE(
    [Total Kwh],'Date'[Year Month Number] = MaxMonthValue)

 

 

Max Month Usages -1 = 
Var MaxMonthValue = 
CALCULATE(
    MAX('Date'[Year Month Number]) -1 ,
    FILTER('Date',[UsagesCount] >= 1),
    ALL('Date'))
    RETURN 
CALCULATE(
    [Total Kwh],'Date'[Year Month Number] = MaxMonthValue)

 

 

UsagesCount = CALCULATE(COUNTROWS('Emporia Device Usage'))

 

 JamesBurke_0-1712830117806.png

 

These measures return the highest Months value ( the Max of the Months where there are usages ) by using the usages count Measure which works until i click or filter down onto a specfic month, The Max Month Usages -1 Then returns a blank value However Max Month usages works. 

 

Desired outcome : 

 

Have Max Month -1 return a value when filtered so the users can look at specfic seleted Months.

 

Thanks , James. 

 

2 REPLIES 2
Anonymous
Not applicable

Hi @JamesBurke ,

 

The core of the issue seems to be related to how the filter context is applied in your DAX formula for "Max Month Usages -1".

 

When you filter down to a specific month, the function's filter context is changed, which affects how the function computes the maximum value of 'Date'[Year Month Number].

 

Please try:

Max Month Usages -1 = 
VAR CurrentMaxMonthValue = 
    CALCULATE(
        MAX('Date'[Year Month Number]),
        ALLSELECTED('Date')
    )
VAR MaxMonthValue = 
    CALCULATE(
        MAX('Date'[Year Month Number]) - 1,
        FILTER(
            ALL('Date'),
            'Date'[Year Month Number] < CurrentMaxMonthValue
            && [UsagesCount] >= 1
        )
    )
RETURN 
    CALCULATE(
        [Total Kwh],
        'Date'[Year Month Number] = MaxMonthValue
    )

 

I would be grateful if you could provide me with sample data for testing, please remove any sensitive data in advance.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hi @Anonymous , 

 

Thanks for this ! unfortunately the issue still remains. 

 

Max Usages -1 Example Data.pbix

 

Attached is some example data  without the sensetive data, It uses my old measurments as well as the one you suggested. 

 

Thanks, James

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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