Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Calculate delta on matrix visual

I am using Matrix visual to display the sales conversion % by year group.  The sales conversion from a calculated measure. Year group comes from grouping function on Year     Matrix visual gives T...
  • sanalytics's avatar
    5 years ago

    Hi Anonymous 

     

    May be you like this way also..Create a index column by dax 

    index = RANKX('Table',[Year (groups)],,ASC)

    then calculate the previous value measure by considering this index column

    VAR _PrevValue=CALCULATE(SUM('Table'[Sales conversion]),FILTER(ALL('Table'),'Table'[index] = MAX('Table'[index])-1) )
    VAR Result = IF(ISBLANK(_PrevValue),BLANK(),_PrevValue- SUM('Table'[Sales conversion]) )
    return
    Result
     
    Hope it helps
    Regards,
    sanalytics
  • mahoneypat's avatar
    5 years ago

    You can use a measure like this to do that.  In the total row, there are multiple year group values, so an IF can be used to return a different calculation there.  This measure will return the difference between the max and min values for the year groups.

     

    Sales Conversion New =
    VAR vSummary =
        ADDCOLUMNS (
            DISTINCT ( YearGroupDifference[Year (groups) 2] ),
            "cSum", [SalesConversion]
        )
    VAR vMax =
        MAXX (
            vSummary,
            [cSum]
        )
    VAR vMin =
        MINX (
            vSummary,
            [cSum]
        )
    RETURN
        IF (
            COUNTROWS ( YearGroupDifference ) = 1,
            vMax,
            vMax - vMin
        )

     

    You can also rename Total to Difference.

     

    Regards,

    Pat

     

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous,

    In fact, the table/matrix visual normally displays the default aggregate mode 'sum' on the total level without any other specific filters.

    mahoneypat 's solution is to modify the total level of table/matrix title to 'difference' and writes the measure formula to check the total row content level and show the corresponding value.

    Clever Hierarchy Handling in DAX 

    For this scenario, you need to manually modify the total level name to change the 'total' to 'difference'. (in format tab -> 'total'/'subtotal' options)

    Regards,

    Xiaoxin Sheng