Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi All,
I am looking for one or two meaures to do conditional calculation(s) instead of building up separate measures.
It's about sort of scoring but requires further conversion per metric criteria and consolidate per the given weight. Below screenshot you can see M01 is given a special conversion than others:
Requests:
1. Is it possible to add conditions within "True Score %" measure and returns the result as "Converted Score %"? What I am looking for is this measure would reflect the average of "Converted Score %" when there is no any filter applied. For example, displying in a Card visualization.
2. Similar to above, is it possible to do one measure with Weight conversion per Metric ID?
Solved! Go to Solution.
Try these measures. I added a Weight column to your table.
Converted Score % =
VAR vTable =
ADDCOLUMNS ( VALUES ( 'Dataset'[Metric ID] ), "@TrueScore", [True Score %] )
VAR vResult =
AVERAGEX ( vTable, IF ( 'Dataset'[Metric ID] = "M01", 1, [@TrueScore] ) )
RETURN
vResult
Weighted Score % =
VAR vTable =
ADDCOLUMNS (
VALUES ( 'Dataset'[Metric ID] ),
"@ConvertedScore", [Converted Score %],
"@Weight", CALCULATE ( MAX ( 'Dataset'[Weight] ) )
)
VAR vResult =
SUMX ( vTable, [@ConvertedScore] * [@Weight] )
RETURN
vResult
Proud to be a Super User!
Try these measures. I added a Weight column to your table.
Converted Score % =
VAR vTable =
ADDCOLUMNS ( VALUES ( 'Dataset'[Metric ID] ), "@TrueScore", [True Score %] )
VAR vResult =
AVERAGEX ( vTable, IF ( 'Dataset'[Metric ID] = "M01", 1, [@TrueScore] ) )
RETURN
vResult
Weighted Score % =
VAR vTable =
ADDCOLUMNS (
VALUES ( 'Dataset'[Metric ID] ),
"@ConvertedScore", [Converted Score %],
"@Weight", CALCULATE ( MAX ( 'Dataset'[Weight] ) )
)
VAR vResult =
SUMX ( vTable, [@ConvertedScore] * [@Weight] )
RETURN
vResult
Proud to be a Super User!
Many thanks for your support. Your DAX calculations hit the goal!! Just let you know that I added a small condition on "Converted Score %" in order to achieve M1's scenarios.
Converted Score % =
VAR vTable =
ADDCOLUMNS ( VALUES ( 'Dataset'[Metric ID] ), "@TrueScore", [True Score %] )
VAR vResult =
//AVERAGEX ( vTable, IF ( 'Dataset'[Metric ID] = "M01", 1, [@TrueScore] ) )
AVERAGEX (
vTable,
IF ( 'Dataset'[Metric ID] = "M01" && [@TrueScore] >= 0.5, 1, [@TrueScore] )
)
RETURN
vResult
Glad to hear the DAX works. Yes, I see that dual criteria now for M01. 🙂
Proud to be a Super User!
User | Count |
---|---|
76 | |
75 | |
46 | |
31 | |
27 |
User | Count |
---|---|
99 | |
91 | |
51 | |
49 | |
45 |