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.
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)
Solved! Go to Solution.
Hi @CarloA93 ,
Based on your description, I have created a simple sample:
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:
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.
Hi @CarloA93 ,
Based on your description, I have created a simple sample:
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:
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
96 | |
79 | |
67 | |
62 |
User | Count |
---|---|
137 | |
106 | |
104 | |
81 | |
63 |