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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
1125NEWBIUSER
Helper I
Helper I

Add filters to existing DAX Coding

Hello,

I am still new to Power BI and DAX Coding. I am working on creating columns to calculate our work in process. We do this by taking the cummulative orders and then subtract cummulative shipped products. Anyway, I have a DAX to do this but need to add two filters to the codes to specify orders and remove a sales type. The code I currently have is:

**bleep** WIP Order Today =
VAR LastVisibleDate =
    MAX ( 'Order/Wip Calculations'[Date] )
VAR FirstVisibleDate =
    MIN ( 'Order/Wip Calculations'[Date] )
VAR LastDateWithSales =
    CALCULATE (
        MAX ( 'Orders/WIP'[Order date] ),
        REMOVEFILTERS ('Orders/WIP')     )
VAR Result =
    IFFirstVisibleDate <= LastDateWithSales,
        CALCULATE (    Sum('Orders/WIP'[Quantity]),
            'Order/Wip Calculations'[Date] <= LastVisibleDate )    )
RETURN
    Result
 
I need to filter the [Quantity] field for the following lines:
'Orders/WIP'[Invoiced] <>"Return" && 'Orders/WIP'[SalesTranType] = 'Standard'
 
Everytime I try adding I get syntex errors and I am not really sure where I can add that it will work. Do I need to make a variable unit field for the filters and then add to general DAX?
 
Thanks, Chris
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@1125NEWBIUSER , 1 of the three ways

 

CALCULATE ( Sum('Orders/WIP'[Quantity]),
'Order/Wip Calculations'[Date] <= LastVisibleDate , 'Orders/WIP'[Invoiced] <>"Return" && 'Orders/WIP'[SalesTranType] = 'Standard')


CALCULATE ( Sum('Orders/WIP'[Quantity]),
'Order/Wip Calculations'[Date] <= LastVisibleDate , filter('Orders/WIP' ,'Orders/WIP'[Invoiced] <>"Return" && 'Orders/WIP'[SalesTranType] = 'Standard') )

 

 

CALCULATE (CALCULATE ( Sum('Orders/WIP'[Quantity]),
'Order/Wip Calculations'[Date] <= LastVisibleDate) , filter('Orders/WIP' ,'Orders/WIP'[Invoiced] <>"Return" && 'Orders/WIP'[SalesTranType] = 'Standard') )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
1125NEWBIUSER
Helper I
Helper I

Thank you, this did the trick!

amitchandak
Super User
Super User

@1125NEWBIUSER , 1 of the three ways

 

CALCULATE ( Sum('Orders/WIP'[Quantity]),
'Order/Wip Calculations'[Date] <= LastVisibleDate , 'Orders/WIP'[Invoiced] <>"Return" && 'Orders/WIP'[SalesTranType] = 'Standard')


CALCULATE ( Sum('Orders/WIP'[Quantity]),
'Order/Wip Calculations'[Date] <= LastVisibleDate , filter('Orders/WIP' ,'Orders/WIP'[Invoiced] <>"Return" && 'Orders/WIP'[SalesTranType] = 'Standard') )

 

 

CALCULATE (CALCULATE ( Sum('Orders/WIP'[Quantity]),
'Order/Wip Calculations'[Date] <= LastVisibleDate) , filter('Orders/WIP' ,'Orders/WIP'[Invoiced] <>"Return" && 'Orders/WIP'[SalesTranType] = 'Standard') )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.