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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.