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

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
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.