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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
alaynanich
Helper I
Helper I

How to aggregate in a measure without actually aggregating?

HI! so I am trying to use the isinscopre function in a matrix to show different transaction count values based on the hierarchy of Event Name -> Offer ID -> SKU. My measure works fine to switch teh values betweek sku and offer, but for osme reason it's showing the total sum of ALL events and not just the associated event. I'm wondering if it's something wrong with my model?

 

Below is the measure

TY Transactions =
VAR sku = SUM('Consolidated SKU Sales'[Total transactions])
VAR offer = SUM('Consolidated Offer'[ty trans count])
VAR event = SUM('Consolidated Events'[ty trans count])

RETURN
IF(
    ISINSCOPE('Consolidated SKU Sales'[SKU]),
    sku,
    IF(
        ISINSCOPE('Consolidated SKU Sales'[Offer Name Tx]),
        offer,
        IF(
            ISINSCOPE('Consolidated SKU Sales'[Event Nm]),
            event
        )
    )
)

 

So from left to right, this is my transactions measure, the count for the event, the count for teh offers for that event (one offer in this example), and the count for differnet sku products. 

alaynanich_3-1718163057506.png

 

Looking across the rows, it works fine except for that event, which is showing the sum of total counts for all. The event, sku,and offer tables are connected with unique keys, and there are unique values of the event id, so i'm not sure why this isn't calulating correctly. Is there a way to just not use Sum at all in my measure, and have it display the correct associated count? Thanks!

alaynanich_1-1718162755619.png

alaynanich_2-1718162865705.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @alaynanich,

After using filter to check the current row contents level, you also need to add correspond filters to these expressions to control calculate the result instead directly use aggregate functions(e.g. sum, average, average) to implicit calculation.

TY Transactions =
VAR sku =
    CALCULATE (
        SUM ( 'Consolidated SKU Sales'[Total transactions] ),
        ALLSELECTED ( 'Consolidated SKU Sales' ),
        VALUES ( 'Consolidated SKU Sales'[SKU] )
    )
VAR offer =
    CALCULATE (
        SUM ( 'Consolidated Offer'[ty trans count] ),
        ALLSELECTED ( 'Consolidated SKU Sales' ),
        VALUES ( 'Consolidated SKU Sales'[SKU] ),
        VALUES ( 'Consolidated SKU Sales'[Offer Name Tx] )
    )
VAR event =
    CALCULATE (
        SUM ( 'Consolidated Events'[ty trans count] ),
        ALLSELECTED ( 'Consolidated SKU Sales' ),
        VALUES ( 'Consolidated SKU Sales'[SKU] ),
        VALUES ( 'Consolidated SKU Sales'[Offer Name Tx] ),
        VALUES ( 'Consolidated SKU Sales'[Event Nm] )
    )
RETURN
    IF (
        ISINSCOPE ( 'Consolidated SKU Sales'[SKU] ),
        sku,
        IF (
            ISINSCOPE ( 'Consolidated SKU Sales'[Offer Name Tx] ),
            offer,
            IF ( ISINSCOPE ( 'Consolidated SKU Sales'[Event Nm] ), event )
        )
    )

Regards,
Xiaoxin Sheng

View solution in original post

2 REPLIES 2
alaynanich
Helper I
Helper I

@Anonymous thank you!! that worked like a charm!

Anonymous
Not applicable

HI @alaynanich,

After using filter to check the current row contents level, you also need to add correspond filters to these expressions to control calculate the result instead directly use aggregate functions(e.g. sum, average, average) to implicit calculation.

TY Transactions =
VAR sku =
    CALCULATE (
        SUM ( 'Consolidated SKU Sales'[Total transactions] ),
        ALLSELECTED ( 'Consolidated SKU Sales' ),
        VALUES ( 'Consolidated SKU Sales'[SKU] )
    )
VAR offer =
    CALCULATE (
        SUM ( 'Consolidated Offer'[ty trans count] ),
        ALLSELECTED ( 'Consolidated SKU Sales' ),
        VALUES ( 'Consolidated SKU Sales'[SKU] ),
        VALUES ( 'Consolidated SKU Sales'[Offer Name Tx] )
    )
VAR event =
    CALCULATE (
        SUM ( 'Consolidated Events'[ty trans count] ),
        ALLSELECTED ( 'Consolidated SKU Sales' ),
        VALUES ( 'Consolidated SKU Sales'[SKU] ),
        VALUES ( 'Consolidated SKU Sales'[Offer Name Tx] ),
        VALUES ( 'Consolidated SKU Sales'[Event Nm] )
    )
RETURN
    IF (
        ISINSCOPE ( 'Consolidated SKU Sales'[SKU] ),
        sku,
        IF (
            ISINSCOPE ( 'Consolidated SKU Sales'[Offer Name Tx] ),
            offer,
            IF ( ISINSCOPE ( 'Consolidated SKU Sales'[Event Nm] ), event )
        )
    )

Regards,
Xiaoxin Sheng

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.