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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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