Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello everyone,
I'm trying to calculate the average of some different values in the same column. And after that, using that result to divide another value in the same column, resulting a value in porcetage.
The example of the table and the equation are shown below:
For ID CODE 41: X =[ 10 / (20+5/2) ] - 1
| | |
TYPE--------------> A B C -> media between B and C
I really appreciate for the help.
Solved! Go to Solution.
// Of course, your notation is incorrect.
// The formula should read:
//
// X = [2A / (B + C)] - 1
//
// In mathematics IT DOES MATTER where you put
// brackets. Note that such a calculation should
// be performed in Power Query, not in DAX.
[New Column] = // column, not a measure
var __code = T[ID Code]
var __a =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "A"
),
T[Value]
)
var __b =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "B"
),
T[Value]
)
var __c =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "C"
),
T[Value]
)
return
DIVIDE(
2 * __a,
__b + __c
) - 1
// If you want a calculated table,
// you can do this:
[Calc Table] =
ADDCOLUMNS(
VALUES( T[ID Code] ),
"X",
var __code = T[ID Code]
var __a =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "A"
),
T[Value]
)
var __b =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "B"
),
T[Value]
)
var __c =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "C"
),
T[Value]
)
return
DIVIDE(
2 * __a,
__b + __c
) - 1
)
Best
D
// Of course, your notation is incorrect.
// The formula should read:
//
// X = [2A / (B + C)] - 1
//
// In mathematics IT DOES MATTER where you put
// brackets. Note that such a calculation should
// be performed in Power Query, not in DAX.
[New Column] = // column, not a measure
var __code = T[ID Code]
var __a =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "A"
),
T[Value]
)
var __b =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "B"
),
T[Value]
)
var __c =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "C"
),
T[Value]
)
return
DIVIDE(
2 * __a,
__b + __c
) - 1
// If you want a calculated table,
// you can do this:
[Calc Table] =
ADDCOLUMNS(
VALUES( T[ID Code] ),
"X",
var __code = T[ID Code]
var __a =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "A"
),
T[Value]
)
var __b =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "B"
),
T[Value]
)
var __c =
MAXX(
filter(
T,
T[ID Code] = __code
&&
T[Type] = "C"
),
T[Value]
)
return
DIVIDE(
2 * __a,
__b + __c
) - 1
)
Best
D
Thank you for the answer. It helpde me a lot.
I just needed to change little things to adapt on my need, but your answer was fundamental.
Best wishes!
Not sure I follow this, but if you want the average of each ID CODE, for example, you could do this:
New Column = AVERAGEX(FILTER('Table',[ID CODE] = EARLIER([ID CODE])),[Value])
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |