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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DLU
Helper I
Helper I

how to combine multiple FIND requirements

Dear community, 

 

I have a dataset with a column that contains different types of transactions. I only need to calculate with values that contain WO,  TO, SO or IC. I tried to solve it with a if and contain function but that didn't work. I've now solved it by creating a calculated column for each type but I think there should be an easier way in DAX. This is my calculated column now: 

 

Workorders = FIND("WO";INVENTTRANSORIG[REFERENCEID];1;0)
 
And I would do the same for the TO, SO and IC 
 
After that I would create the next calculated column to come to an overall selection: 
 
Included transactions = SWITCH(TRUE();INVENTTRANSORIG[Workorders]=1;1;
INVENTTRANSORIG[Salesorders]=1;1;
INVENTTRANSORIG[Term orders]=1;INVENTTRANSORIG[IC orders]=1;
1;0)
 
And after that I would calculate my needed value with:
 
 Total number of transactions = Calculate(SUMX(INVENTTRANSORIG;INVENTTRANSORIG[QTY]);INVENTTRANSORIG[Included transactions]=1)
 
Does anyone have an idea how I can put all this into 1 DAX formula to prevent performance issues?
Many thanks in advance!
5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hi @DLU ,

 

Has the problem be solved?

Please consider to mark the reply as solution if it's helpful.

 

 

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

No unfortunately my problem wasn't solved. I've now solved it by adjusting my SQL query and already filtering that, so I can't accept any responses with the solution

rsbin
Super User
Super User

@DLU ,

Appears to me, you want to make use of the IN function in DAX. So something like this:

Number of Transactions = CALCULATE( SUM( Inventory[QTY]),
                              FILTER(Inventory, Inventory[ReferenceID] IN { "WO", "TO", "SO", "IC" } ))

rsbin_0-1668609656285.png

Not sure if you need to use SUM or SUMX depending on your specific purpose.

Hope this gives you some ideas to simplify your DAX.

Regards,

 

 

Dear  rsbin, 

 

I've tried and I'm not getting an error but I'm not getting any data either. Just for your information. The referenceID is never only WO or SO etc. The WO is part of a bigger number like WO-001 or TXN-WO001. Could that now be the problem? 

 

Regards, Diana

@DLU ,

Yes, that is the problem.  Based on your description, I assumed the Column value was simply the 2 character code.  I would suggest you create another Calculated Column isolating the codes you are searching for.  There are a number of DAX Text functions similar to those in Excel that can be used to extract these codes from the bigger number.

https://learn.microsoft.com/en-us/dax/text-functions-dax

Hope you are able to carry forward.  If not, please post sample data as a table (not an image) and I will try to find some time to assist.

Regards,

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.