cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
beachikeen11 Frequent Visitor
Frequent Visitor

Summarize IDs with only one type of transaction

Goal: A field that returns the number customers who only have return transactions, a distinct count of Unique_IDs that have only one transaction_type and where that transaction_type=B.

 

Based on the definition, I think the calculation(s) need to first determine the IDs that have only one transaction type. Of those IDs, determine which have transaction_type=B, and then return the distinct count of remaining IDs. I’m having troubling stringing these steps together to produce the correct population of IDs. Do I need to create a relationship between the summarize table and the transaction table..? Or am I missing a function, or applying them in an order that changes that incorrectly alters the filter context?

 

This summarize correctly counts transaction types for each ID:

Customers Grouped by Transaction_Type =

SUMMARIZE(

    'TRANSACTION',

    'TRANSACTION'[Unique_ID],

    "Grouped by ID Returns",

    DISTINCTCOUNT('TRANSACTION'[Transaction_Type])

)

 

This field calc produces the count of customers with returns, but does not correctly filter out customers that have returns and purchases.

TEST Returns Only Customers=

    CALCULATE(

        DISTINCTCOUNT('TRANSACTION'[Unique_ID]),

        FILTER(

VALUES (‘Customers Grouped by Transaction_Type’[Unique_ID]),

[Grouped by ID Returns]=1
),

FILTER(

'TRANSACTION',

[Transaction_type]=“B”

)
)

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Summarize IDs with only one type of transaction

@beachikeen11,

 

You may refer to the measure below.

Measure =
COUNTROWS (
    FILTER (
        VALUES ( 'TRANSACTION'[Unique_ID] ),
        CALCULATE ( SELECTEDVALUE ( 'TRANSACTION'[Transaction_Type] ) = "B" )
    )
)
Community Support Team _ Sam Zha
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

2 REPLIES 2
Community Support Team
Community Support Team

Re: Summarize IDs with only one type of transaction

@beachikeen11,

 

You may refer to the measure below.

Measure =
COUNTROWS (
    FILTER (
        VALUES ( 'TRANSACTION'[Unique_ID] ),
        CALCULATE ( SELECTEDVALUE ( 'TRANSACTION'[Transaction_Type] ) = "B" )
    )
)
Community Support Team _ Sam Zha
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

beachikeen11 Frequent Visitor
Frequent Visitor

Re: Summarize IDs with only one type of transaction

Power BI automatically marked the solution as correct. While it may work for someone, it will not work for this case. The suggested syntax incorrectly assumes that each Unique ID corresponds to a single row. However, the data in this case is at the level of Transaction ID, which is more granular than the Unique ID. Since each Unique ID is associated with multiple Transaction IDs, it is not sufficient to use COUNTROWS and it will produce a count that is too high. 

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 48 members 663 guests
Please welcome our newest community members: