Forum Discussion
keckraguilar
2 years agoFrequent Visitor
Measure is creating duplicate rows in a table
I am trying to sum charges for the two previous months. The grand total is right but the grand total is duplicating down every row. Below are the two DAX formulas I am using. I think the issue is wit...
- Anonymous2 years ago
Hi keckraguilar ,
You can change your expression to something like this.
Total Charges Current Month = VAR __CurrentPatient = SELECTEDVALUE ( 'Volume Files'[Patient Encounter - Service Line 2] ) VAR __MaxMonth = MAXX ( ALL ( 'Volume Files' ), 'Volume Files'[Month Number] ) VAR __Result = CALCULATE ( SUM ( 'Volume Files'[Total Charges] ), FILTER ( ALL ( 'Volume Files' ), [Month Number] = __MaxMonth && 'Volume Files'[Discharge Date - Fiscal Year] = "FY2024" && 'Volume Files'[Patient Encounter - Service Line 2] = __CurrentPatient ) ) VAR __total = CALCULATE ( SUM ( 'Volume Files'[Total Charges] ), FILTER ( ALLSELECTED ( 'Volume Files' ), [Month Number] = __MaxMonth && 'Volume Files'[Discharge Date - Fiscal Year] = "FY2024" ) ) RETURN IF ( ISINSCOPE ( 'Volume Files'[Patient Encounter - Service Line 2] ), __Result, __total )Total Charges Previous Month = VAR __CurrentPatient = SELECTEDVALUE ( 'Volume Files'[Patient Encounter - Service Line 2] ) VAR __MaxMonth = MAXX ( ALL ( 'Volume Files' ), 'Volume Files'[Month Number] ) VAR __Result = CALCULATE ( SUM ( 'Volume Files'[Total Charges] ), FILTER ( ALL ( 'Volume Files' ), [Month Number] = __MaxMonth - 1 && 'Volume Files'[Discharge Date - Fiscal Year] = "FY2024" && 'Volume Files'[Patient Encounter - Service Line 2] = __CurrentPatient ) ) VAR __total = CALCULATE ( SUM ( 'Volume Files'[Total Charges] ), FILTER ( ALLSELECTED ( 'Volume Files' ), [Month Number] = __MaxMonth - 1 && 'Volume Files'[Discharge Date - Fiscal Year] = "FY2024" ) ) RETURN IF ( ISINSCOPE ( 'Volume Files'[Patient Encounter - Service Line 2] ), __Result, __total )If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
2 years agoNot applicable
Hi keckraguilar ,
You can change your expression to something like this.
Total Charges Current Month =
VAR __CurrentPatient =
SELECTEDVALUE ( 'Volume Files'[Patient Encounter - Service Line 2] )
VAR __MaxMonth =
MAXX ( ALL ( 'Volume Files' ), 'Volume Files'[Month Number] )
VAR __Result =
CALCULATE (
SUM ( 'Volume Files'[Total Charges] ),
FILTER (
ALL ( 'Volume Files' ),
[Month Number] = __MaxMonth
&& 'Volume Files'[Discharge Date - Fiscal Year] = "FY2024"
&& 'Volume Files'[Patient Encounter - Service Line 2] = __CurrentPatient
)
)
VAR __total =
CALCULATE (
SUM ( 'Volume Files'[Total Charges] ),
FILTER (
ALLSELECTED ( 'Volume Files' ),
[Month Number] = __MaxMonth
&& 'Volume Files'[Discharge Date - Fiscal Year] = "FY2024"
)
)
RETURN
IF (
ISINSCOPE ( 'Volume Files'[Patient Encounter - Service Line 2] ),
__Result,
__total
)
Total Charges Previous Month =
VAR __CurrentPatient =
SELECTEDVALUE ( 'Volume Files'[Patient Encounter - Service Line 2] )
VAR __MaxMonth =
MAXX ( ALL ( 'Volume Files' ), 'Volume Files'[Month Number] )
VAR __Result =
CALCULATE (
SUM ( 'Volume Files'[Total Charges] ),
FILTER (
ALL ( 'Volume Files' ),
[Month Number] = __MaxMonth - 1
&& 'Volume Files'[Discharge Date - Fiscal Year] = "FY2024"
&& 'Volume Files'[Patient Encounter - Service Line 2] = __CurrentPatient
)
)
VAR __total =
CALCULATE (
SUM ( 'Volume Files'[Total Charges] ),
FILTER (
ALLSELECTED ( 'Volume Files' ),
[Month Number] = __MaxMonth - 1
&& 'Volume Files'[Discharge Date - Fiscal Year] = "FY2024"
)
)
RETURN
IF (
ISINSCOPE ( 'Volume Files'[Patient Encounter - Service Line 2] ),
__Result,
__total
)
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.