Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Advance Aggregation / Sum with rounding

Hello Expert,  Here is what we are trying to do and completely lost the thought process while getting the formula.  Step 3 will be based on the variance. If the variance is 1, applies to one acc, i...
  • v-eachen-msft's avatar
    v-eachen-msft
    7 years ago

    Hi Anonymous ,

     

    According to the results of your picture, I grouped the data in ActualValue.

    So the actual total value of this group is 54(10.7*5). How to explain the "AAA-005" has two diffenrent values if you need to group the data in AccType.

    I am sorry that I ignored the "10" . Here is the new DAX:

    Step4 =
    VAR _rank =
        RANKX (
            FILTER ( 'Table', 'Table'[ActualValue] = EARLIER ( 'Table'[ActualValue] ) ),
            'Table'[AccType],
            ,
            ASC,
            DENSE
        )
    VAR _step1 =
        CALCULATE (
            SUM ( 'Table'[RoundedValue] ) - SUM ( 'Table'[ActualValue] ),
            ALLEXCEPT ( 'Table', 'Table'[AccGroup] )
        )
    VAR _step2 =
        IF ( _step1 < 0, INT ( _step1 ) + 1, INT ( _step1 ) )
    VAR _step3 =
        IF (
            ABS ( _step2 ) < _rank
                && ABS ( _step2 ) <= 10,
            0,
            IF ( _step2 < 0, 1, -1 )
        )
    RETURN
        'Table'[RoundedValue] + _step3