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
CarloA93
Frequent Visitor

Average of all 'Calculated Percent Changes'

CarloA93_0-1665508322901.png

 

I'm wondering if it was possible to get an average of all peoples' Percent Changes (which was a custom measure). In other words, add all the percent changes in the table and divide by the sample size.

 

For the calculation I created a measure with this formula (below) and was able to show each individual person’s percent change using a Matrix, but I’m not sure how I can perform this calculation on those numbers (under Percent Change).

 

Percent Change = DIVIDE(

CALCULATE(SUM(WeightData[Weight]),WeightData[Date]=Max(WeightData[Date])) - 
CALCULATE(SUM(WeightData[Weight]),WeightData[Date]=Min(WeightData[Date])),
CALCULATE(SUM(WeightData[Weight]),WeightData[Date]=Max(WeightData[Date])),0)

 

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

Hi @CarloA93 ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1665543256119.png

Please try:

Average Percent Change =
VAR _a =
    DISTINCT ( SELECTCOLUMNS ( 'WeightData', "PatientName", [Patient Name] ) )
VAR _b =
    ADDCOLUMNS (
        _a,
        "PercentageChange",
            (
                DIVIDE (
                    CALCULATE (
                        SUM ( WeightData[Weight] ),
                        FILTER (
                            'WeightData',
                            [Patient Name] = EARLIER ( [PatientName] )
                                && [Date]
                                    = MAXX (
                                        FILTER ( 'WeightData', [Patient Name] = EARLIER ( [PatientName] ) ),
                                        [Date]
                                    )
                        )
                    )
                        - CALCULATE (
                            SUM ( WeightData[Weight] ),
                            FILTER (
                                'WeightData',
                                [Patient Name] = EARLIER ( [PatientName] )
                                    && [Date]
                                        = MINX (
                                            FILTER ( 'WeightData', [Patient Name] = EARLIER ( [PatientName] ) ),
                                            [Date]
                                        )
                            )
                        ),
                    CALCULATE (
                        SUM ( WeightData[Weight] ),
                        FILTER (
                            'WeightData',
                            [Patient Name] = EARLIER ( [PatientName] )
                                && [Date]
                                    = MAXX (
                                        FILTER ( 'WeightData', [Patient Name] = EARLIER ( [PatientName] ) ),
                                        [Date]
                                    )
                        )
                    ),
                    0
                )
            )
    )
RETURN
    AVERAGEX ( _b, [PercentageChange] )

Final output:

vjianbolimsft_1-1665543319142.png

Best Regards,

Jianbo Li

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

Hi @CarloA93 ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1665543256119.png

Please try:

Average Percent Change =
VAR _a =
    DISTINCT ( SELECTCOLUMNS ( 'WeightData', "PatientName", [Patient Name] ) )
VAR _b =
    ADDCOLUMNS (
        _a,
        "PercentageChange",
            (
                DIVIDE (
                    CALCULATE (
                        SUM ( WeightData[Weight] ),
                        FILTER (
                            'WeightData',
                            [Patient Name] = EARLIER ( [PatientName] )
                                && [Date]
                                    = MAXX (
                                        FILTER ( 'WeightData', [Patient Name] = EARLIER ( [PatientName] ) ),
                                        [Date]
                                    )
                        )
                    )
                        - CALCULATE (
                            SUM ( WeightData[Weight] ),
                            FILTER (
                                'WeightData',
                                [Patient Name] = EARLIER ( [PatientName] )
                                    && [Date]
                                        = MINX (
                                            FILTER ( 'WeightData', [Patient Name] = EARLIER ( [PatientName] ) ),
                                            [Date]
                                        )
                            )
                        ),
                    CALCULATE (
                        SUM ( WeightData[Weight] ),
                        FILTER (
                            'WeightData',
                            [Patient Name] = EARLIER ( [PatientName] )
                                && [Date]
                                    = MAXX (
                                        FILTER ( 'WeightData', [Patient Name] = EARLIER ( [PatientName] ) ),
                                        [Date]
                                    )
                        )
                    ),
                    0
                )
            )
    )
RETURN
    AVERAGEX ( _b, [PercentageChange] )

Final output:

vjianbolimsft_1-1665543319142.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you. I think this will work, but I will let you know if I have any questions.

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.