Forum Discussion
To Help understand DAX MEASURE | RANKX | Filter Context | Row Context
- 3 years ago
Please try
M1 =SUMX(VALUES(FactMemberQualityMeasures[QMID]),VAR CurrentQMID =FactMemberQualityMeasures[QMID]RETURNSUMX (CALCULATETABLE(VALUES ( FactMemberQualityMeasures[MemberID] )),VAR QM2_data =CALCULATETABLE(FactMemberQualityMeasures,FactMemberQualityMeasures[QMID] IN { 10, 11, 12, 13 },ALL ( DimQualityMeasures[QMID]))VAR QM2_Dataset =TOPN ( 1, QM2_data, FactMemberQualityMeasures[RISK_RANK], ASC )VAR maxQMID =MAXX(QM2_Dataset, FactMemberQualityMeasures[QMID])RETURNIF(CurrentQMID = maxQMID,SUMX ( QM2_Dataset, FactMemberQualityMeasures[DENOMINATOR] ))))
selvakumarr
Ok, Let me simplify my question; What result are you expecting to see at the total level in this screenshot?
| QMID | | Q Num Current | | Q Num Expected |
| 10 | 5195 | 4924 |
| 11 | 36 | 35 |
| 12 | 125 | 123 |
| 13 | 94 | 94 |
| Total | 5176 | 5176 |
If you look the value for QM 10 current implementation, it says 5195 which is greater than the total and why it is greater than Total because the expression is being evaluated for QM 10, taking the QM10 item and finding the lowest risk in that population to sum the numerator. For each reporting row the TOPN population changed with respect to current row context.
I want to calculate total at selected Months level and then split that number for each category like it is split in Q Num Expected column.
In a nutshell:
Total should match to sum of Unique patient's Numerator within selected time frame. (Which is matching now)
Sum of Individual rows should match to Total. (It is not happening)
- tamerj13 years agoCommunity Champion
I hope you understand that I don't see what you see. I don't have your data, data model or report to look at and fully understand the situation. I got the general Ideas but the issue is to get the correct results. Please try
=
VAR SelectedTable =
FILTER ( ALLSELECTED ( FactPatient ), FactPatient[QMID] IN { 10, 11, 12, 13 } )
RETURN
SUMX (
VALUES ( FactPatient[Member ID] ),
VAR CurrentID = FactPatient[Member ID]
VAR QM2_data =
FILTER ( SelectedTable, FactPatient[Member ID] = CurrentID )
VAR QM2_Dataset =
TOPN ( 1, QM2_data, FactPatient[Ranked_Risk], ASC )
RETURN
SUMX ( QM2_Dataset, FactPatient[NUMERATOR] )
) - tamerj13 years agoCommunity Champion
selvakumarr
Now I got you.Please try
= SUMX ( VALUES ( FactPatient[Member ID] ), VAR QM2_data = CALCULATETABLE ( FactPatient, FactPatient[QMID] IN { 10, 11, 12, 13 } ) VAR QM2_Dataset = TOPN ( 1, QM2_data, FactPatient[Ranked_Risk], ASC ) RETURN SUMX ( QM2_Dataset, FactPatient[NUMERATOR] ) ) - selvakumarr3 years agoFrequent Visitor
Hi tamerj1 , Thanks for patiently replying to my queries and I am sorry that this solution still evaluates the whole expression for each QMID (Row level Context).
If I have to rephrase my query, There are two parts to this,
Until QM2_Dataset, I want to evaluate based on User applied filters, and only the final sum expression needs to be assessed in row context.
I have tried to put the logic which I have in my mind in the screen shot below.
I want a Temp table expression evaluated for the current filter context and then apply the sum function on the temp table created.