Forum Discussion
Combine two measures
- 6 years ago
Sorry I didn't get back to you earlier.
Please try to wrap the measures by a calculate.
New Measure = sumx('Table', if('Table'[Socket_id ] in {550, 639, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 679, 681, 682, 683}, Calculate([EnergyUsedInPeriod1]), Calculate([EnergyUsed])))
Can you try this out:
New Column = IF(socket_id in {550, 639, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 679, 681, 682, 683}, [Energy Used in Period 1], [Energy Used])
This will use the "Energy Used In Period 1" for the socket ids mentioned between {} and will use "Energy Used" for all other socket ids.
If you are going to have more than those two cases, then I suggest to use Switch statement instead of If statement, like that:
New Column = Switch(True(), socket_id in {550, 639, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 679, 681, 682, 683}, [Energy Used in Period 1], socket_id in {677,678,680}, [Energy Used], socket_id in {n,n1,n2}, Measure3, Else Value)
Using switch, you can add several conditions and have an "Else Value" in the end for any row that doesn't meet any of the conditions.
If Statement Reference: https://docs.microsoft.com/en-us/dax/if-function-dax
Swtich Statement Reference: https://docs.microsoft.com/en-us/dax/switch-function-dax
Best Regards
- PSRai6 years agoHelper III
unfortunately I get the following error message
A circular dependency was detected: readings_true_energy[New Column], readings_true_energy[MaxEnrgy], readings_true_energy[New Column].
- helassal6 years agoResolver II
PSRai ,
I tried to reproduce the error, but it is working ok for me. Please check this sample file.
However, it is possible to have an underlying reason for the circular dependency, in that case, check this thread with a similar problem and how to attepmt to solve it.
Hope this helps.
- PSRai6 years agoHelper III
Thanks, Can't seem to get around the circular reference. any other suggestions?