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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Sweet-T
Helper III
Helper III

Check if all columns have specific value, otherwise displays those that don't

Good morning everyone, 

 

I have multiple columns that contribute to deciding if an item is ready for payment. To be eligible for payment, all columns must be "Ready for Payment". I'd like to find a way (I'm thinking function or variables in DAX) to validate if each column for a given row meets my criteria, otherwise I'd like it to display the string(s) of the column(s) that do not meet my criteria.

In the following example, "Payment Eligibility" is my primary desired result, but if it is very difficult to concatenate and spit out the strings that don't meet the criteria, "Payment Eligibility 2.0" would be my next ask. 

 

ItemColumn AColumn BColumn CPayment EligibilityPayment Eligibility 2.0
1Ready for PaymentReady for PaymentReady for PaymentReady for PaymentReady for Payment
2Ready for PaymentB IncompleteReady for PaymentB IncompleteIncomplete
3A IncompleteB IncompleteReady for PaymentA Incomplete, B IncompleteIncomplete

 

Hopefully someone out there has encountered something similar. Thanks in advance!

Happy Tuesday,

T

 

2 ACCEPTED SOLUTIONS
v-lili6-msft
Community Support
Community Support

hi, @Sweet-T

You could try to use SEARCH Function to add a new column

Result = IF(SEARCH("Ready for Payment",'Table'[Column A],1,0)>0&&SEARCH("Ready for Payment",'Table'[Column B],1,0)>0&&SEARCH("Ready for Payment",'Table'[Column C],1,0)>0,"Ready for Payment",
IF(SEARCH("Ready for Payment",'Table'[Column A],1,0)=0,'Table'[Column A])&IF(SEARCH("Ready for Payment",'Table'[Column B],1,0)=0,'Table'[Column B])&IF(SEARCH("Ready for Payment",'Table'[Column C],1,0)=0,'Table'[Column C]))
Result 2.0 = IF(SEARCH("Ready for Payment",'Table'[Column A],1,0)>0&&SEARCH("Ready for Payment",'Table'[Column B],1,0)>0&&SEARCH("Ready for Payment",'Table'[Column C],1,0)>0,"Ready for Payment","	Incomplete")

6.JPG

 

By the way, Whether you do not put a comma between two fields, since these are three separate columns, that will be difficult to get it.

 

Best Regards,

Lin

Community Support Team _ Lin
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

AlB
Community Champion
Community Champion

@Sweet-T

 

Another version, with ", " as delimiter and cleaning up the string to avoid ", " at the end

 

Payment Eligibility2 =
VAR _SearchString = "Ready for Payment"
VAR _ResultString =
    IF ( Table1[Column A] <> _SearchString, Table1[Column A] & ", " )
        & IF ( Table1[Column B] <> _SearchString, Table1[Column B] & ", " )
        & IF ( Table1[Column C] <> _SearchString, Table1[Column C] )
VAR _CleanResultString =
    IF (NOT ( ISBLANK ( _ResultString ) ),
        IF (RIGHT ( _ResultString, 2 ) = ", ",
            LEFT ( _ResultString, LEN ( _ResultString ) - 2 )
        ),
        _ResultString
    )
RETURN
    IF ( ISBLANK ( _CleanResultString ), _SearchString, _CleanResultString )

 

Code formatted with   www.daxformatter.com

 

View solution in original post

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi, @Sweet-T

You could try to use SEARCH Function to add a new column

Result = IF(SEARCH("Ready for Payment",'Table'[Column A],1,0)>0&&SEARCH("Ready for Payment",'Table'[Column B],1,0)>0&&SEARCH("Ready for Payment",'Table'[Column C],1,0)>0,"Ready for Payment",
IF(SEARCH("Ready for Payment",'Table'[Column A],1,0)=0,'Table'[Column A])&IF(SEARCH("Ready for Payment",'Table'[Column B],1,0)=0,'Table'[Column B])&IF(SEARCH("Ready for Payment",'Table'[Column C],1,0)=0,'Table'[Column C]))
Result 2.0 = IF(SEARCH("Ready for Payment",'Table'[Column A],1,0)>0&&SEARCH("Ready for Payment",'Table'[Column B],1,0)>0&&SEARCH("Ready for Payment",'Table'[Column C],1,0)>0,"Ready for Payment","	Incomplete")

6.JPG

 

By the way, Whether you do not put a comma between two fields, since these are three separate columns, that will be difficult to get it.

 

Best Regards,

Lin

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

Thanks Lin, this would work well!
AlB
Community Champion
Community Champion

Hi @Sweet-T

 

How about this for an initial version of new column 'Payment Eligibility'?

 

Payment Eligibility =
VAR _SearchString = "Ready for Payment"
VAR _ResultString =
    IF ( Table1[Column A] <> _SearchString, Table1[Column A] & " " )
        & IF ( Table1[Column B] <> _SearchString, Table1[Column B] & " " )
        & IF ( Table1[Column C] <> _SearchString, Table1[Column C] )
RETURN
    IF ( ISBLANK ( __ResultString ), _SearchString, __ResultString )

  The code would probably be simpler if the table was unpivoted to have a structure as:

 

ItemColumnValue
1AReady for Payment
1BReady for Payment
1CReady for Payment
2AReady for Payment
2BB Incomplete
2CReady for Payment
3AA Incomplete
3BB Incomplete
3CReady for Payment
AlB
Community Champion
Community Champion

@Sweet-T

 

Another version, with ", " as delimiter and cleaning up the string to avoid ", " at the end

 

Payment Eligibility2 =
VAR _SearchString = "Ready for Payment"
VAR _ResultString =
    IF ( Table1[Column A] <> _SearchString, Table1[Column A] & ", " )
        & IF ( Table1[Column B] <> _SearchString, Table1[Column B] & ", " )
        & IF ( Table1[Column C] <> _SearchString, Table1[Column C] )
VAR _CleanResultString =
    IF (NOT ( ISBLANK ( _ResultString ) ),
        IF (RIGHT ( _ResultString, 2 ) = ", ",
            LEFT ( _ResultString, LEN ( _ResultString ) - 2 )
        ),
        _ResultString
    )
RETURN
    IF ( ISBLANK ( _CleanResultString ), _SearchString, _CleanResultString )

 

Code formatted with   www.daxformatter.com

 

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.