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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors
Top Kudoed Authors