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
Cado_one
Resolver III
Resolver III

Summarize a summarized table

Hi everyone,

 

Context : I need to display values with different aggregations in a matrix on 4 levels.

- Level 1 : raw values from a source table

- Level 2 : sum of the level 1 values by month for a location

- Level 3 : average of the level 2 values for a location

- Level 4 : average of the level 3 values (no filter, it corresponds to the bottom total line)

 

I face an issue in this measure :

 

Measure = 

VAR Table1 = SUMMARIZE(Source, [LOCATIONS], [MONTH], "SumMonths", SUM(Source[Values]))
VAR Table2 = SUMMARIZE(Table1, [LOCATIONS], "AverageLocations", AVERAGE([SumMonths]))

RETURN
IF(
    ISINSCOPE(Dates[Month]),
    SUM(Source[Values]),
    IF(
        ISINSCOPE(Source[LOCATIONS]),
        AVERAGEX(Table1, [SumMonths]),
        AVERAGEX(Table2, [AverageLocations])
    )
)

 

The values returned by the measure are correct in the matrix for level 1, 2 and 3 but then I have an error with the AVERAGE([SumMonths]) at the end of the second VAR. It doesn't recognize the summarized column of the Table1.

Does anyone has an idea of how this could be handled ?

 

Thanks in advance,

Cado

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Cado_one,

You can try to use the following measure formulas if helps:

Formula =
VAR t1 =
    SUMMARIZE ( Source, [LOCATIONS], [MONTH], "SumMonths", SUM ( Source[Values] ) )
VAR t2 =
    SUMMARIZE (
        Source,
        [LOCATIONS],
        "AverageLocations",
            AVERAGEX (
                FILTER ( t1, [LOCATIONS] = EARLIER ( Source[LOCATIONS] ) ),
                [SumMonths]
            )
    )
RETURN
    IF (
        ISINSCOPE ( Dates[Month] ),
        SUM ( Source[Values] ),
        IF (
            ISINSCOPE ( Source[LOCATIONS] ),
            AVERAGEX ( t1, [SumMonths] ),
            AVERAGEX ( t2, [AverageLocations] )
        )
    )

If the above formula also doesn't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

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

Hi @Cado_one,

You can try to use the following measure formulas if helps:

Formula =
VAR t1 =
    SUMMARIZE ( Source, [LOCATIONS], [MONTH], "SumMonths", SUM ( Source[Values] ) )
VAR t2 =
    SUMMARIZE (
        Source,
        [LOCATIONS],
        "AverageLocations",
            AVERAGEX (
                FILTER ( t1, [LOCATIONS] = EARLIER ( Source[LOCATIONS] ) ),
                [SumMonths]
            )
    )
RETURN
    IF (
        ISINSCOPE ( Dates[Month] ),
        SUM ( Source[Values] ),
        IF (
            ISINSCOPE ( Source[LOCATIONS] ),
            AVERAGEX ( t1, [SumMonths] ),
            AVERAGEX ( t2, [AverageLocations] )
        )
    )

If the above formula also doesn't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

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

Hi @v-shex-msft 

 

it's working thanks !

 

Best regards,

Cado

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.