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?
Hi Anonymous ,
Thank you very much. However, I feel that the difference between a column and a measure is not being understood, and it feels somewhat like I'm conversing with Copilot. A measure cannot take the form of a Fully Qualified Reference, meaning that you cannot write 'Table'[Measure3] in the conditions of the Calculate function. Keeping this in mind, I would like a correct response that truly works.
mh20221111 I'll try to help here (unless someone else does first).
Could I just check the filter condition:
Did you want the filter to select Sizes for which
- 0 ≤ [Measure3] ≤ Parameter; or
- ( [Measure3] = 0 ) AND ( Size ≤ Parameter )
To test an example, assuming a parameter value of 50, which sizes in the table in your original would be included?
- 0 ≤ [Measure3] ≤ 50: Sizes 14.6, 15.0, 15.4, 15.8, and 16.1
- ( [Measure3] = 0 ) AND ( Size ≤ 50 ): Size 16.1 only
Regards
- mh202211111 year ago
Helper II
Hi OwenAuger ,
The expected behavior is that when the parameter value is 50, the calculations will be based on the values for sizes 14.6, 15.0, 15.4, 15.8, and 16.1( where 0 ≤ [Measure3] ≤ 50).
Regards,
mh20221111- OwenAuger1 year ago
Super User
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?
- mh202211111 year ago
Helper II
Hi OwenAuger
Thank you for your guidance. Thanks to your help, it seems that I will be able to implement what I want to do!
Regards,
mh20221111