Forum Discussion

quincy_p's avatar
quincy_p
Advocate I
2 years ago
Solved

Create New Column based on Value found between Quotation Marks

Hi - I am tring to create a new column as I need to pull an "asset ID" number from a error dialogue line.    The table is called 'Work Order ALL' and the the nubmer is found in [Integration_Result_...
  • EylesIT's avatar
    2 years ago

    quincy_p, here is my suggested solution.

     

    I am using a test data table of one row with one column called [Integration_Result__c] which contains the full text of the error message you posted

    Error CS_ServiceRequest_PUB.Create_ServiceRequest API Programming Error (CS_ServiceRequest_UTIL.Validate_Customer_Product): The value "111448692" for field p_customer_product_id is invalid.

     

    I then created a Calculated Column with this DAX expression:

    assetID = 
        VAR search1 = "(CS_ServiceRequest_UTIL.Validate_Customer_Product): The value """
        VAR search2 = """ for field p_customer_product_id is invalid"
        VAR pos1 = FIND(search1, YourTable[Integration_Result__c], 1, 0)
        VAR pos2 = FIND(search2, YourTable[Integration_Result__c], 1, 0)
        VAR assetID = 
            SWITCH(TRUE(),
                pos1 > 0 && pos2 > 0, 
                MID(
                    YourTable[Integration_Result__c],
                    pos1 + LEN(search1),
                    pos2 - pos1 - LEN(search1)
                )
            )
        RETURN assetID

     

    This gives me the following output:

     

    Is this what you were looking for?