Forum Discussion

Roseventura's avatar
Roseventura
Icon for Responsive Resident rankResponsive Resident
7 years ago
Solved

Column Totals are not Correct even when using HASONEVALUE()

I need to understand why my measures in columns 2 and 4 are not totalling correctly. 

 

Here is my table.

Here are the measures for each column:

 

COLUMN 1:

Total Credit Adjustment =

       IF(MAX(PBI_FSCAPF[PADFMO]) =3 ||MAX(PBI_FSCAPF[PADFMO]) =6 || MAX(PBI_FSCAPF[PADFMO]) =9

         ||MAX(PBI_FSCAPF[PADFMO]) =12 ,-375000,-300000)

 

COLUMN 2:

Credit Adjustment Total =
    VAR CREDIT_ADJUSTMENT = [Total Credit Adjustment]
    VAR TOTAL_ADJUSTED_CREDIT = SUMMARIZE(PBI_FSCAPF,PBI_FSCAPF[YEAR-MO], "Monthly Adj", CREDIT_ADJUSTMENT )
RETURN
    IF( HASONEVALUE('PBI_FSCAPF'[YEAR-MO] ),
        CREDIT_ADJUSTMENT ,
            SUMX( TOTAL_ADJUSTED_CREDIT, [Monthly Adj] ) )

 

COLUMN 3:

Credit Adjusment Less Inv Credits = [Total Credit Adjustment]-[Total Inv Credits]

 

COLUMN 4:

Credit Adjustment Less Inv Credits Total =
    VAR CREDIT_ADJUSTMENT_INV_CREDITS = [Credit Adjusment Less Inv Credits]
    VAR TOTAL_ADJUSTED_AND_INV_CREDITS = SUMMARIZE(PBI_FSCAPF,PBI_FSCAPF[YEAR-MO], "Adjustment by Month",

        CREDIT_ADJUSTMENT_INV_CREDITS )
RETURN
    IF( HASONEVALUE('PBI_FSCAPF'[YEAR-MO] ),
        CREDIT_ADJUSTMENT_INV_CREDITS ,
            SUMX( TOTAL_ADJUSTED_AND_INV_CREDITS, [Adjustment by Month] ) )

 

Note:  PBI_FSCAPF is my DATE table.

  • Roseventura's avatar
    Roseventura
    7 years ago

    I discovered that the MAX function in my original TOTAL CREDIT ADJUSTMENT measure was the culprit.  Here's the original measure:

     

    Total Credit Adjustment =
           IF(MAX(PBI_FSCAPF[PADFMO]) =3 ||MAX(PBI_FSCAPF[PADFMO]) =6 || MAX(PBI_FSCAPF[PADFMO]) =9  ||

               MAX(PBI_FSCAPF[PADFMO]) =12 ,-375000,-300000)

     

    This was an issue in the total, because the MAX results is always calculating to 12 and therefore 375,000 * 3 = 1,125,000 (which was the incorrect total I was getting).  As soon as I removed MAX() it worked and I didn't have to use a HASONEVALUE branch measure.  This corrected measure gave me the results I wanted:

     

    Total Credit Adjustment = SUMX( VALUES( PBI_FSCAPF[PADFMO] ),IF(PBI_FSCAPF[PADFMO] =3 || PBI_FSCAPF[PADFMO] = 6 || PBI_FSCAPF[PADFMO] =9 || PBI_FSCAPF[PADFMO] =12 ,-375000,-300000))

     

    This change makes the other “branched” measure work:

     

    Credit Adjusment Less Inv Credits = [Total Credit Adjustment]-[Total Inv Credits]

    capture2

     

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Does you Date table go back further than 2018-10?  Totals and Subtotals are calculated without any filters and each cell is caclulated independantly.  

    • Roseventura's avatar
      Roseventura
      Icon for Responsive Resident rankResponsive Resident

      I discovered that the MAX function in my original TOTAL CREDIT ADJUSTMENT measure was the culprit.  Here's the original measure:

       

      Total Credit Adjustment =
             IF(MAX(PBI_FSCAPF[PADFMO]) =3 ||MAX(PBI_FSCAPF[PADFMO]) =6 || MAX(PBI_FSCAPF[PADFMO]) =9  ||

                 MAX(PBI_FSCAPF[PADFMO]) =12 ,-375000,-300000)

       

      This was an issue in the total, because the MAX results is always calculating to 12 and therefore 375,000 * 3 = 1,125,000 (which was the incorrect total I was getting).  As soon as I removed MAX() it worked and I didn't have to use a HASONEVALUE branch measure.  This corrected measure gave me the results I wanted:

       

      Total Credit Adjustment = SUMX( VALUES( PBI_FSCAPF[PADFMO] ),IF(PBI_FSCAPF[PADFMO] =3 || PBI_FSCAPF[PADFMO] = 6 || PBI_FSCAPF[PADFMO] =9 || PBI_FSCAPF[PADFMO] =12 ,-375000,-300000))

       

      This change makes the other “branched” measure work:

       

      Credit Adjusment Less Inv Credits = [Total Credit Adjustment]-[Total Inv Credits]

      capture2