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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

Table with Conditional Calculated Column from another Table

Hello!

I need to create a newtable ( TABLE2), which has unique clients filtered from another table(TABLE1).

The main TABLE1 contains the following columns:

DateClientStateCodeCommentExecutive Number
21-01-2021502Success1789CUSTOMER PAYS FULL DEBT1353
07-01-2021502Failure1789DOES NOT SUBSCRIBE TO CONVENTION474
21-01-20214502Failure 1600WRONG FONO608
30-12-202028502Success1788CUSTOMER PAYS TO DEBT 818
13-01-202150214Failure 1787DOES NOT SUBSCRIBE TO CONVENTION 555

As you can see, in this table, in the CUSTOMER column, there are two customers, with different order states.

For this, I created a new table(TABLE 2)that so far contains a column with different clients,

I mean:

Client
502
4502
28502
50214

What I want to do is that to each client I want to assign the STATUS of TABLE1 as follows: if the client has two associated states (one SUCCESS and one FAILURE, such as CLIENT 502), I want the SUCCESS state to be prioritized (i.e., do not take into account their FAILURE status), which would remain in this case:

EXAMPLE 1

ClientState
502Success
4502Failure
28502Success
50214Failure

EXAMPLE 2

on the other hand if the client becomes associated with two states (FAILURE AND FAILURE, or EXIT AND EXITO) the last of the date made is prioritized.

EXAMPLE TABLE (TABLE1 BUT WITH OTHER ROWS)

DateClientStateCodeCommentExecutive Number
13-01-202125Success1602CUSTOMER SUBSCRIBES AGREEMENT1120
11-01-202190FAILURE -DOES NOT LIVE IN PROPERTY1601DOESN'T LIVE ON THE PROPERTY608
07-01-202190Failure1601DOESN'T LIVE IN PROPERTY608

this would remain in TABLE2 as:

ClientState
25Success
90FAILURE- DOES NOT LIVE IN PROPERTY

I hope to have been clear, I will be attentive to your comments.

Thank you!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Syndicate_Admin here is the DAX expression for the calculated table that will take care of it.

 

Client = 
SUMMARIZE ( 
    'Client Data', 
    'Client Data'[Client],
    "State",
    COALESCE ( 
        CALCULATE ( MIN ( 'Client Data'[State] ), 'Client Data'[State] = "Success" ),
        CALCULATE ( MIN ( 'Client Data'[State] ), TOPN ( 1, ALL ( 'Client Data'[State] ), CALCULATE ( MAX ( 'Client Data'[Date] ) ), DESC ) )
    )
)

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

1 REPLY 1
parry2k
Super User
Super User

@Syndicate_Admin here is the DAX expression for the calculated table that will take care of it.

 

Client = 
SUMMARIZE ( 
    'Client Data', 
    'Client Data'[Client],
    "State",
    COALESCE ( 
        CALCULATE ( MIN ( 'Client Data'[State] ), 'Client Data'[State] = "Success" ),
        CALCULATE ( MIN ( 'Client Data'[State] ), TOPN ( 1, ALL ( 'Client Data'[State] ), CALCULATE ( MAX ( 'Client Data'[Date] ) ), DESC ) )
    )
)

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.