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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
anil
Helper III
Helper III

YTD with month filter using Direct Query

Hi All,

       I am trying to create YTD sales at category level with Month filter using power bi direct query.

If we select month filter value"March" the expected result should be the YTD sum till March.

But in direct query mode, I am unable to use YTD functions. 

 I have tried using this calculated measure but it's not giving YTD result at the

YTD = VAR lastDay =
    MAX ( A2[ORDER_RECEIVED_DATE_NEW] )
VAR year =
    YEAR ( lastDay )
RETURN
    CALCULATE (
        SUM ( A2[Quantity] ),
        FILTER (
            ALL ( A2 ),
            YEAR ( A2[ORDER_RECEIVED_DATE_NEW]) = year
                && A2[ORDER_RECEIVED_DATE_NEW] <= lastDay
        )
    )

category level.

 

please help me with a solution.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Anil

 

Can you please try using ALLEXCEPT instead of ALL since you are looking to see the data at the category level.

 

https://msdn.microsoft.com/en-us/query-bi/dax/allexcept-function-dax

 

Best regards.

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi Anil

 

Can you please try using ALLEXCEPT instead of ALL since you are looking to see the data at the category level.

 

https://msdn.microsoft.com/en-us/query-bi/dax/allexcept-function-dax

 

Best regards.

 

@Anonymous 

Thanks for the reply.

Previously I used allexcpet(), but it was not working. Now I tried again, able to see the expected result.

Anonymous
Not applicable

Cool, thanks for confirming.

Please mark my answer as accepted solution, will help others as well. 🙂

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

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.