Forum Discussion
Adjusting the Total Range Based on User-Selected Parameter Values
- 1 year ago
Thanks mh20221111 🙂
I'm assuming that
- Parameter Value is a measure returning the parameter value.
- Measure1 and Measure2 need to be evaluated for each Commodity/SIZE then summed (but easily adjusted if you just need to evaluate per SIZE then sum).
This would then be the Sum Measure1 measure:
Sum Measure1 = VAR ParameterValue = [Parameter Value] VAR Result = SUMX ( SUMMARIZE ( 'Table', 'Table'[Commodity], 'Table'[SIZE] ), VAR Measure3Value = [Measure3] RETURN IF ( AND ( Measure3Value >= 0, Measure3Value <= ParameterValue ), [Measure1] ) ) RETURN ResultIf Measure1 and Measure2 produce the same result whether summed per Commodity/SIZE or evaluated as-is, you could write this:
Sum Measure1 v2 = VAR ParameterValue = [Parameter Value] VAR CommoditySIZE = FILTER ( SUMMARIZE ( 'Table', 'Table'[Commodity], 'Table'[SIZE] ), VAR Measure3Value = [Measure3] RETURN AND ( Measure3Value >= 0, Measure3Value <= ParameterValue ) ) VAR Result = CALCULATE ( [Measure1], CommoditySIZE ) RETURN ResultYou can change the SUMMARIZE expression to VALUES ( 'Table'[SIZE] ) if you don't need Commodity to be included.
Does this work for you?
mh20221111 Hi!
FilteredMeasure1Sum =
VAR SelectedSizeValue = SELECTEDVALUE('ParameterTable'[SelectedSize])
RETURN
CALCULATE(
SUM('Table'[Measure1]),
'Table'[Measure3] = 0,
'Table'[SIZE] <= SelectedSizeValue
)
FilteredMeasure2Sum =
VAR SelectedSizeValue = SELECTEDVALUE('ParameterTable'[SelectedSize])
RETURN
CALCULATE(
SUM('Table'[Measure2]),
'Table'[Measure3] = 0,
'Table'[SIZE] <= SelectedSizeValue
)
If these measures are incorrect, please sgare the measures in table and I'll try to fix.
BBF
Thank you. By the way, the measures 1 to 3 are not columns in the table but are measures defined by formulas. Can measures also be used as filter conditions in the CALCULATE function?
mh
- BeaBF1 year ago
Super User
mh20221111 Yes, adjusted:
FilteredMeasure1Sum =
VAR SelectedSizeValue = SELECTEDVALUE('ParameterTable'[SelectedSize])
RETURN
CALCULATE(
[Measure1], -- Calculate Measure1 in the filtered context
'Table'[Measure3] = 0, -- Filter condition 1
'Table'[SIZE] <= SelectedSizeValue -- Filter condition 2
)FilteredMeasure2Sum =
VAR SelectedSizeValue = SELECTEDVALUE('ParameterTable'[SelectedSize])
RETURN
CALCULATE(
[Measure2], -- Calculate Measure2 in the filtered context
'Table'[Measure3] = 0, -- Filter condition 1
'Table'[SIZE] <= SelectedSizeValue -- Filter condition 2
)BBF