Forum Discussion
Khalefa
3 years agoHelper I
Iteration with multiple column conditions
Hi team Need support in the below a measure to calculate the overall attribute score on the review ID granularity considering the below:- 1- There are 6 attributes in each review id 2- The DAX sh...
- 3 years ago
Hi Khalefa
Please refer to attached amended sample fileWeighted Score = SUMX ( VALUES ( 'Fact'[Review ID] ), IF ( 0 IN CALCULATETABLE ( VALUES ( 'Fact'[Score] ), ALL ( Dim_Attribute[Attribute] ), Dim_Attribute[Attribute] IN { "Compliance", "Image" } ), 0, SUMX ( CALCULATETABLE ( 'Fact' ), 'Fact'[Score] * RELATED ( Dim_Attribute[Weight] ) / 100 ) ) )Total Weight = SUMX ( VALUES ( 'Fact'[Review ID] ), SUMX ( CALCULATETABLE ( 'Fact' ), RELATED ( Dim_Attribute[Weight] ) ) )% Score = DIVIDE ( [Weighted Score], [Total Weight] )
tamerj1
3 years agoCommunity Champion
Khalefa
Please refer to attached sample file with the final solution.
Weighted Score =
SUMX (
VALUES ( 'Fact'[Review ID] ),
IF (
0
IN CALCULATETABLE (
VALUES ( 'Fact'[Score] ),
Dim_Attribute[Attribute] IN { "Compliance", "Image" }
),
0,
SUMX (
CALCULATETABLE ( 'Fact' ),
'Fact'[Score] * RELATED ( Dim_Attribute[Weight] ) / 100
)
)
)Total Weight =
SUMX (
VALUES ( 'Fact'[Review ID] ),
SUMX (
CALCULATETABLE ( 'Fact' ),
RELATED ( Dim_Attribute[Weight] )
)
)% Score =
DIVIDE (
[Weighted Score],
[Total Weight]
)- Khalefa3 years agoHelper I
tamerj1 thanks a lot, it works but if you don't mind, i need to add a small part which is:-
need to keep the condition of ( Compliance and Image ) active even if filtered by the slicer on the category.
by other means the condition must be applied even if i filtered by category3 ( which doesn't contain either compliance or image )
- Khalefa3 years agoHelper I
tamerj1 it doesn't work as category 3 (Validation & Language) in review ID 2 should be Zero since there is a compliance of zero.
I updated the data on the drive as wellhttps://drive.google.com/drive/folders/1Zkd_6sS582BE8NfHxITV1Gku4njHsk4A?usp=sharing