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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
PowerBI123456
Post Partisan
Post Partisan

Determine codes by account

Hi,

 

I have 2 tables. My fact table: showing which codes are on an account and my dimension table: showing the codes. Here is a sample file. Sample File 

 

PowerBI123456_0-1616619663081.png

PowerBI123456_2-1616619696323.png

 

I am trying to determine which accounts have codes A & B using a measure. I am using the measure below but my results are coming up as blank even though I know it should be 2 (accounts 1 and 2).  Please help. 

PowerBI123456_3-1616619739169.png

 

 

3 REPLIES 3
selimovd
Super User
Super User

Hey @PowerBI123456 ,

 

it took a few minutes, but the following measure should give you the desired result:

Amount Code A & B = 
// Summarize all rows with Activity Code A or B
VAR tTable =
    SUMMARIZE(
        FILTER( 'FACT: Activity', 'FACT: Activity'[Code] IN { "A", "B" } ),
        'FACT: Activity'[Accounts],
        'FACT: Activity'[Code]
    )

// Group results by amount of rows
VAR tGroupBy =
    GROUPBY(
        tTable,
        'FACT: Activity'[Accounts],
        "Row Counts", COUNTX( CURRENTGROUP(), 1 )
    )

// Filter result to results with row count = 2 (Means A and B)
// And count the amount Accounts that have A and B
VAR result =
    COUNTX( FILTER( tGroupBy, [Row Counts] = 2 ), [Row Counts] )
RETURN
    result

 

I added a few comments to make it more understandable.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hey @PowerBI123456 ,

 

I was wondering if my measure worked and solved your problem?

 
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

@selimovd Apologies for the delay in response, it does work! However, my activity file is super large, 10+ million rows. Anyway to use the dimesnion table to filter instead for better performance? 

Helpful resources

Announcements
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.