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
JKPBI
Frequent Visitor

Calculated Column Identifier based on if a particular condition is satisfied in Data Table

Hi all, it's hard to put into words for the title what I'm looking for, but (hopefully) simpler in the DAX

Really, what I'm looking to do is create a calculated column in my lookup table that will show TRUE for any user that has any actions which had multiple 'parts', and label them as a 'Multi-Part Person' forever if they had even one action which needed multiple parts.

See the below example, looking to populate with the highlighted.

The two tables have an INACTIVE relationship between them, which I'm having issues trying to overcome. I was trying to do this using CONTAINS() but I think it's too much of a zero-sum function that was returning if any of them fulfilled the criteria.

 

Table 1 (Data)

User RecordNameDateAction NumberAction Parts
11Jon1/2/20224450
22Bob1/3/20224410
11Jon1/4/20226670
22Bob1/5/20227785
33Sue1/6/202244010
44Jill1/7/20229990

 

Table 2 (Lookup)

User RecordNameAddressOther DemographicMulti-Part Person
11JonJon AddressJon DemographicFALSE
22BobBob AddressBob DemographicTRUE
33SueSue AddressSue DemographicTRUE
44JillJill AddressJill DemographicFALSE

 

Thank you for any help!

1 ACCEPTED SOLUTION

Hi @JKPBI ,

According to your description, I modify your sample data.

Table1:

vkalyjmsft_0-1655192125613.png

Here's my solution. Create a calculated column.

Multi-Part Person =
IF (
    SUMX (
        FILTER (
            'Table1',
            'Table1'[User Record] = EARLIER ( Table2[User Record] )
                && 'Table1'[Action Parts] <> 1
        ),
        'Table1'[Action Parts]
    ) > 0,
    TRUE,
    FALSE
)

Get the correct result.

vkalyjmsft_1-1655192178507.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

4 REPLIES 4
JKPBI
Frequent Visitor

Hi Tom:

 

Yes, actually that does work, but I think I've failed to illustrate the whole problem.

 

There will be many records that have [Action Parts] which are 1 .. so I would not be looking for them to be TRUE but will be in your example because it's SUMing them. 

 

Having just run it, I have Users who have many records with only 1 Action Part that are coming up TRUE just because the SUM of all the 1 parts.

 

Apologies for the oversight, and thank you for the help, especially if there's a way around this new part.

JKPBI
Frequent Visitor

@tackytechtom I wonder if a MAX function can plug in there and if it's greater than 1? I can't seem to get it to work

Hi @JKPBI ,

According to your description, I modify your sample data.

Table1:

vkalyjmsft_0-1655192125613.png

Here's my solution. Create a calculated column.

Multi-Part Person =
IF (
    SUMX (
        FILTER (
            'Table1',
            'Table1'[User Record] = EARLIER ( Table2[User Record] )
                && 'Table1'[Action Parts] <> 1
        ),
        'Table1'[Action Parts]
    ) > 0,
    TRUE,
    FALSE
)

Get the correct result.

vkalyjmsft_1-1655192178507.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

tackytechtom
Super User
Super User

Hi @JKPBI ,

 

How about this:

tomfox_0-1654542474969.png

 

Here the DAX code for the calculated column:

Multi-Part Person = 
IF ( 
    Table34b[User Record] in ( FILTER ( VALUES ( Table34a[User Record] ), CALCULATE ( SUM ( 'Table34a'[Action Parts] ) > 0 ) ) ), 
    TRUE, 
    FALSE 
)

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/

 



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

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.