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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

CALCULATE with FILTER by Row Grouping

I've got this DAX that produces the correct result for the total quantity from 3 months previous.  However, when I drag Transaction Type into my table, I still get that total result, but I was expecting to now see that total carved up by Transaction Type.  What do I modify to get this to behave appropriately?

Ordered Qty Prev 3 Months Total TEST =
VAR __PREV_MONTH =
    EOMONTH (
        MAX ( 'Supply_Chain Orders'[Ship Date] ),
        -1
    )
VAR __PREV_MONTH3 =
    EOMONTH (
        MAX ( 'Supply_Chain Orders'[Ship Date] ),
        -4
    )
RETURN
    CALCULATE (
        SUM ( 'Supply_Chain Orders'[Ordered Quantity] ),
        FILTER (
            ALL ( 'Supply_Chain Orders' ),
            'Supply_Chain Orders'[Ship Date].[Date] > __PREV_MONTH3
                && 'Supply_Chain Orders'[Ship Date].[Date] <= __PREV_MONTH
        )
    )





 

 




1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

Can you try this : 

Ordered Qty Prev 3 Months Total TEST =
VAR __PREV_MONTH =
    EOMONTH ( MAX ( 'Supply_Chain Orders'[Ship Date] ), -1 )
VAR __PREV_MONTH3 =
    EOMONTH ( MAX ( 'Supply_Chain Orders'[Ship Date] ), -4 )
RETURN
    CALCULATE (
        SUM ( 'Supply_Chain Orders'[Ordered Quantity] ),
        FILTER (
            ALL ( 'Supply_Chain Orders'[Ship Date].[Date] ),
            'Supply_Chain Orders'[Ship Date].[Date] > __PREV_MONTH3
                && 'Supply_Chain Orders'[Ship Date].[Date] <= __PREV_MONTH
        )
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks!  ALL function had to be on specific column, not on whole table.  

Fowmy
Super User
Super User

@Anonymous 

Can you try this : 

Ordered Qty Prev 3 Months Total TEST =
VAR __PREV_MONTH =
    EOMONTH ( MAX ( 'Supply_Chain Orders'[Ship Date] ), -1 )
VAR __PREV_MONTH3 =
    EOMONTH ( MAX ( 'Supply_Chain Orders'[Ship Date] ), -4 )
RETURN
    CALCULATE (
        SUM ( 'Supply_Chain Orders'[Ordered Quantity] ),
        FILTER (
            ALL ( 'Supply_Chain Orders'[Ship Date].[Date] ),
            'Supply_Chain Orders'[Ship Date].[Date] > __PREV_MONTH3
                && 'Supply_Chain Orders'[Ship Date].[Date] <= __PREV_MONTH
        )
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors