Forum Discussion
Calculation giving the same value against every row
- Anonymous3 years ago
Thanks tamerj1 for your time and effort to get this calculation correct.
What I discovered later is that the problem was not with the DAX witten by me. I was making use of column 'Hours of Operational Use' from wrong table which was causing this problem. After changing the table, the same DAX started giving the correct output. Please see below snapshot.
But I must admit that your modified DAX version is simple and easy to understand.
Thanks Again for your quick help. Much appreciated. Cheers.
HI Anonymous
Apparently you have created a calculated column instead of a measure. Just use the same DAX in a measure and it should wok. However, here is an improved version of the DAX
vTotalUptime =
VAR Days = [vTotalDaysInPeriod]
VAR BusinessDays = [vBusinessDaysInPeriod]
RETURN
SUMX (
VALUES ( 'Service Availability'[Hours Of Operational Use] ),
SWITCH (
'Service Availability'[Hours Of Operational Use],
"24x7",
Days * 24 * 60,
"Business Hours",
BusinessDays * 9 * 60,
"Extended Hours - 7 days",
Days * 13 * 60,
"Extended Hours - 5 days",
BusinessDays * 13 * 60
)
)
Make sure [vTotalDaysInPeriod] and [vTotalDaysInPeriod] are also measures not calculated columns. Please let me know if they are in fact columns in the source data table.
Thanks tamerj1 for your time and effort to get this calculation correct.
What I discovered later is that the problem was not with the DAX witten by me. I was making use of column 'Hours of Operational Use' from wrong table which was causing this problem. After changing the table, the same DAX started giving the correct output. Please see below snapshot.
But I must admit that your modified DAX version is simple and easy to understand.
Thanks Again for your quick help. Much appreciated. Cheers.