Forum Discussion
Obiweka
3 years agoRegular Visitor
Creating a measure calculation using the IF or Switch and True function
Please I would like some help to write a Measure in Power Bi using IF or Switch function to calculate carbon emission (carbon emission= Total weight x emission factor) based on data contained in two ...
- Anonymous3 years ago
Hi Obiweka ,
You can create a calculated column as below in Table1 to get it:
Column = VAR _efactor = CALCULATE ( MAX ( 'Table2'[Emission Factor] ), FILTER ( 'Table2', 'Table2'[Waste Types] = [Waste Description] && 'Table2'[Disposal Facility] = [Disposal Facility Type] ) ) RETURN [Total Weight (Tonnes)] * _efactorBest Regards
Anonymous
3 years agoNot applicable
Hi Obiweka ,
You can create a calculated column as below in Table1 to get it:
Column =
VAR _efactor =
CALCULATE (
MAX ( 'Table2'[Emission Factor] ),
FILTER (
'Table2',
'Table2'[Waste Types] = [Waste Description]
&& 'Table2'[Disposal Facility] = [Disposal Facility Type]
)
)
RETURN
[Total Weight (Tonnes)] * _efactor
Best Regards
- Obiweka3 years agoRegular Visitor
Thank you Anonymous. The solution works. However, please I would like to know if it is also possible for this to be done as a measure as I was hoping to avoid adding an extra column because it will result to errors when I try to combine subsequent sheets.
- Anonymous3 years agoNot applicable
Hi Obiweka ,
If you need to create a measure instead of a calculated column, you need to make a little adjustment. When you put the measure on the visual, the field [Waste Description], [Disposal Facility Type] and [Total Weight (Tonnes)] in Table1 should also be put on the visual.
Measurve = VAR _efactor = CALCULATE ( MAX ( 'Table2'[Emission Factor] ), FILTER ( 'Table2', 'Table2'[Waste Types] = SELECTEDVALUE ( 'Table1'[Waste Description] ) && 'Table2'[Disposal Facility] = SELECTEDVALUE ( 'Table1'[Disposal Facility Type] ) ) ) RETURN SELECTEDVALUE ( 'Table1'[Total Weight (Tonnes)] ) * _efactorBest Regards