Forum Discussion
Two tables - creating a measure/column
- Anonymous2 years ago
You may try using SELECTEDVALUE function to get the distinct value of each percentage used in the calculation. As these percentages are from two tables, it would be better to use a measure.
For example (I only extract some part from your formula):
Adjusted OR = IF ( SELECTEDVALUE ( 'OR Report'[Line Result] ) - SELECTEDVALUE ( 'OR Report'[ Planned OR%] ) < 0, SELECTEDVALUE ( 'OR Report'[Line Result] ) - ( SELECTEDVALUE ( 'OR Report'[Line Result] ) - SELECTEDVALUE ( 'OR Report'[ Planned OR%] ) ) * SELECTEDVALUE ( 'Downtime Report'[% of DT Minutes] ), SELECTEDVALUE ( 'OR Report'[Line Result] ) + ( SELECTEDVALUE ( 'OR Report'[Line Result] ) - SELECTEDVALUE ( 'OR Report'[ Planned OR%] ) ) * SELECTEDVALUE ( 'Downtime Report'[% of DT Minutes] ) )or
Adjusted OR = VAR vLineResult = SELECTEDVALUE ( 'OR Report'[Line Result] ) VAR vPlannedORPct = SELECTEDVALUE ( 'OR Report'[ Planned OR%] ) VAR vDTMinutesPct = SELECTEDVALUE ( 'Downtime Report'[% of DT Minutes] ) RETURN IF ( vLineResult - vPlannedORPct < 0, vLineResult - ( vLineResult - vPlannedORPct ) * vDTMinutesPct, vLineResult + ( vLineResult - vPlannedORPct ) * vDTMinutesPct )Here are some docs for your reference:
SELECTEDVALUE function - DAX | Microsoft Learn
VAR keyword (DAX) - DAX | Microsoft Learn
Use variables to improve your DAX formulas - DAX | Microsoft Learn
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
You may try using SELECTEDVALUE function to get the distinct value of each percentage used in the calculation. As these percentages are from two tables, it would be better to use a measure.
For example (I only extract some part from your formula):
Adjusted OR =
IF (
SELECTEDVALUE ( 'OR Report'[Line Result] ) - SELECTEDVALUE ( 'OR Report'[ Planned OR%] ) < 0,
SELECTEDVALUE ( 'OR Report'[Line Result] ) - ( SELECTEDVALUE ( 'OR Report'[Line Result] ) - SELECTEDVALUE ( 'OR Report'[ Planned OR%] ) ) * SELECTEDVALUE ( 'Downtime Report'[% of DT Minutes] ),
SELECTEDVALUE ( 'OR Report'[Line Result] ) + ( SELECTEDVALUE ( 'OR Report'[Line Result] ) - SELECTEDVALUE ( 'OR Report'[ Planned OR%] ) ) * SELECTEDVALUE ( 'Downtime Report'[% of DT Minutes] )
)
or
Adjusted OR =
VAR vLineResult = SELECTEDVALUE ( 'OR Report'[Line Result] )
VAR vPlannedORPct = SELECTEDVALUE ( 'OR Report'[ Planned OR%] )
VAR vDTMinutesPct = SELECTEDVALUE ( 'Downtime Report'[% of DT Minutes] )
RETURN
IF (
vLineResult - vPlannedORPct < 0,
vLineResult - ( vLineResult - vPlannedORPct ) * vDTMinutesPct,
vLineResult + ( vLineResult - vPlannedORPct ) * vDTMinutesPct
)
Here are some docs for your reference:
SELECTEDVALUE function - DAX | Microsoft Learn
VAR keyword (DAX) - DAX | Microsoft Learn
Use variables to improve your DAX formulas - DAX | Microsoft Learn
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!