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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
maashi
Frequent Visitor

Vlookup, multiple filters

I have been trying to replicate something I had been doing very manually on Excel, involving a VLOOKUP then counting non blanks in the result. I have attached the sample data for that purpose, and this is the working to replicate it in Power BI.

 

Working Column =
var _order = 'Table2_2'[Original Sales Order]
Return
MAXX(FILTER('Table2_2','Table2_2'[Sales Order No]=_order),'Table2_2'[Sales Order No])
 
New Measure :
NCP on NCP = DISTINCTCOUNT('Table2_2'[Working Column])

 
But then I realised, the sample data has already been filtered out once. How do I add in another filter so I only need to use one working column (If possible)?
Basically, in the return part of the working column, as well as looking up the 'original order number' in earlier lines to see if it has already appeared, it also needs to look up to see if order type of the earlier order number matches one of two specific  types. I tried using lookupvalue to create a second working column (to look up the first working column result to see if it is the correct sales order type) and the result was just a mess, because each sales order can appear multiple times (although in the real original data there is another identifier column to show what the line number is in each sales order number).
 
I have added the sales order type in the sample data column, have made it all one type (because that is correct for this data) but what if there are other sales order types? And I don't want those included in the maxx filter? I guess to summarise, how do i put in a second filter into the maxx function so that not only is it looking for the var to have appeared earlier in a different column, it also looks to make sure the sales order type is correct?
 
Hope this explanation is clear enough and thanks for the help.
 
1 ACCEPTED SOLUTION
v-jiewu-msft
Community Support
Community Support

Hi @maashi ,

I can not see the sales order type in the sample data.

vjiewumsft_0-1718955162805.png

Based on the description, try to use the following dax formula.

Working Column =
VAR _order = 'Table2_2'[Original Sales Order]
RETURN
    MAXX(
        FILTER(
            'Table2_2',
            'Table2_2'[Sales Order No] = _order &&
            'Table2_2'[Sales Order Type] IN {"Type1", "Type2"}
        ),
        'Table2_2'[Sales Order No]
    )

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-jiewu-msft
Community Support
Community Support

Hi @maashi ,

I can not see the sales order type in the sample data.

vjiewumsft_0-1718955162805.png

Based on the description, try to use the following dax formula.

Working Column =
VAR _order = 'Table2_2'[Original Sales Order]
RETURN
    MAXX(
        FILTER(
            'Table2_2',
            'Table2_2'[Sales Order No] = _order &&
            'Table2_2'[Sales Order Type] IN {"Type1", "Type2"}
        ),
        'Table2_2'[Sales Order No]
    )

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much, that worked seamlessly. Much appreciated. Marcy

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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