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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
alaynanich
Frequent Visitor

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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
alaynanich
Frequent Visitor

@v-shex-msft thank you!! that worked like a charm!

v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.