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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
kumsha1
Post Patron
Post Patron

DAX to get Monthly totals based on specific filters

Can someone help to check what's wrong with below DAX, it's stopped working recently where VAR SA is not returning any values now....

Our requirement is to get the monthly totals for the selected month, year and attribute, would greatly help if there's any other easy way to do this..TIA

 

 

MTDPlanValue (Monthly) =
VAR SM =
MONTH ( SELECTEDVALUE ( 'CALENDAR'[CALENDAR_DATE] ) )
VAR SY =
YEAR ( SELECTEDVALUE ( 'CALENDAR'[CALENDAR_DATE] ) )
VAR SA =
SELECTEDVALUE ( 'AttributeInfo'[Attribute] )
RETURN
CALCULATE (
SUM( 'Stg_PPD DailyReporting_Live_V'[DAILY_PLAN_VALUE] ),
FILTER (
ALL ( 'CALENDAR' ),
'CALENDAR'[CALENDAR_MONTH] = SM
&& 'CALENDAR'[CALENDAR_YEAR] = SY
),
FILTER (
ALL ( 'AttributeInfo' ),
'AttributeInfo'[Attribute] = SA
)
)

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I assume there are some cases end users select more than two attributes.

If end users keep selecting only one year and only one month, but selecting more than two attributes, and if this is considered as a correct behavior, please try the below.

 

MTDPlanValue (Monthly) =
VAR SM =
    MONTH ( SELECTEDVALUE ( 'CALENDAR'[CALENDAR_DATE] ) )
VAR SY =
    YEAR ( SELECTEDVALUE ( 'CALENDAR'[CALENDAR_DATE] ) )
VAR SA =
    VALUES ( 'AttributeInfo'[Attribute] )
RETURN
    CALCULATE (
        SUM ( 'Stg_PPD DailyReporting_Live_V'[DAILY_PLAN_VALUE] ),
        FILTER (
            ALL ( 'CALENDAR' ),
            'CALENDAR'[CALENDAR_MONTH] = SM
                && 'CALENDAR'[CALENDAR_YEAR] = SY
        ),
        FILTER ( ALL ( 'AttributeInfo' ), 'AttributeInfo'[Attribute] IN SA )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

@Jihwan_Kim , users will select one year/month and attribute only...i have tried below simple DAX and it's not returning any value, what could be wrong here, any ideas.. TIA

 

MTDPlanValue (Monthly) =
VAR SA =
    SELECTEDVALUE ( 'AttributeInfo'[Attribute] )
RETURN
    SA

Hi,

It is difficult for me to tell what is going on without seeing your pbix file.

Please try the below measure whether it is returning one value or not. 

 

Checking: =
VAR SA =
    VALUES ( 'AttributeInfo'[Attribute] )
RETURN
    CONCATENATEX ( SA, 'AttributeInfo'[Attribute], ", " )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Ashish_Mathur
Super User
Super User

Hi,

If your Year and Month slicer are from the Calendar table, then this simple measure should work

=SUM( 'Stg_PPD DailyReporting_Live_V'[DAILY_PLAN_VALUE] )

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur , this measure should always give the Monthly total (for selected month, year and attribute) not the day total.

 

kumsha1_0-1681183865340.png

 

I am still very confused about what you want.  Try this measure

Measure = calculate(SUM( 'Stg_PPD DailyReporting_Live_V'[DAILY_PLAN_VALUE] ),datesbetween(calendar[date],eomoth(min(calendar[date]),-1)+1,eomoth(min(calendar[date]),0))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors