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
JothiG
Helper III
Helper III

Help help - Dax correction

JothiG_0-1757399394993.png

Hi, 
 I have requirement area chart as like shown in above. area area should show the value of last month value break up in series label . for example (2025 should show the August month value but not all month sum).
below dax not working

var _yr = max('yarn data'[Stock_finyear])

var _max_month = CALCULATE(
MAXX(
    FILTER(ALL('yarn data'),'yarn data'[Stock_finyear]=_yr),
    'yarn data'[month_sorter]
)
)
var sum_val = CALCULATE(
SUM('yarn data'[value])
,
    FILTER(ALL('yarn data'),'yarn data'[Stock_finyear]=_yr),
    'yarn data'[value]
)

RETURN
sum_val
1 ACCEPTED SOLUTION
v-saisrao-msft
Community Support
Community Support

Hi @JothiG,

Thank you @FarhanJeelani, for your insights.

I reproduced your issue with sample data and was able to create the issue in Power BI. I made the chart and verified the results. I've attached the PBIX file for your reference.

Last Month Value = 
VAR _yr = MAX('yarn data'[Stock_finyear])
VAR _max_month =
    CALCULATE (
        MAX ( 'yarn data'[month_sorter] ),
        FILTER ( ALL ( 'yarn data' ), 'yarn data'[Stock_finyear] = _yr )
    )
RETURN
CALCULATE (
    SUM ( 'yarn data'[Value] ),
    'yarn data'[Stock_finyear] = _yr,
    'yarn data'[month_sorter] = _max_month
)

 

Thank you.

View solution in original post

7 REPLIES 7
v-saisrao-msft
Community Support
Community Support

Hi @JothiG,

Checking in to see if your issue has been resolved. let us know if you still need any assistance.

 

Thank you.

yeah. it's working now.

Hi @JothiG,

Thank you for the update. Could you please share the steps you took to resolve the issue? This information would be helpful for other community members.

 

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @JothiG,

Have you had a chance to review the solution we shared earlier? If the issue persists, feel free to reply so we can help further.

 

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @JothiG,

Thank you @FarhanJeelani, for your insights.

I reproduced your issue with sample data and was able to create the issue in Power BI. I made the chart and verified the results. I've attached the PBIX file for your reference.

Last Month Value = 
VAR _yr = MAX('yarn data'[Stock_finyear])
VAR _max_month =
    CALCULATE (
        MAX ( 'yarn data'[month_sorter] ),
        FILTER ( ALL ( 'yarn data' ), 'yarn data'[Stock_finyear] = _yr )
    )
RETURN
CALCULATE (
    SUM ( 'yarn data'[Value] ),
    'yarn data'[Stock_finyear] = _yr,
    'yarn data'[month_sorter] = _max_month
)

 

Thank you.

FarhanJeelani
Super User
Super User

Hi @JothiG ,

The issue is that sum_val is summing all months in the year (and you even have an invalid filter expression 'yarn data'[value]).

You need to filter the sum to only the last month of that year.

 

You can try the approach that returns the value for the last month of the current year context (and works well when the visual shows Year on the axis).

Using SELECTEDVALUE (works well when Year is in the visual axis)

Last Month Value = VAR _yr = SELECTEDVALUE('yarn data'[Stock_finyear]) VAR _lastMonth = CALCULATE( MAX('yarn data'[month_sorter]), ALL('yarn data'), 'yarn data'[Stock_finyear] = _yr ) RETURN IF( NOT ISBLANK(_yr), CALCULATE( SUM('yarn data'[value]), ALL('yarn data'), 'yarn data'[Stock_finyear] = _yr, 'yarn data'[month_sorter] = lastMonth ), BLANK() )

 or,

If you prefer MAX context (works similarly when there’s a single year in context)

Last Month Value = VAR _yr = MAX('yarn data'[Stock_finyear]) VAR _lastMonth = CALCULATE( MAX('yarn data'[month_sorter]), ALL('yarn data'), 'yarn data'[Stock_finyear] = _yr ) RETURN CALCULATE( SUM('yarn data'[value]), ALL('yarn data'), 'yarn data'[Stock_finyear] = _yr, 'yarn data'[month_sorter] = _lastMonth )

 

Please mark this post as solution if it helps you. Appreciate Kudos.

it is also not working ...

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.