Forum Discussion

JoyceW's avatar
JoyceW
Helper II
3 years ago
Solved

Group by margin %

I have a table with sales order lines from the last 3 years. I have revenue and costs and measures to calculate the margin and margin percentage. now I would like to create a visual that shows how...
  • FreemanZ's avatar
    FreemanZ
    3 years ago

    hi JoyceW 

    you would need

    1) a table named Range like this:

    RangeMinMax
    <8%-100.00%7.99%
    8-10%8.00%10.00%
    >10%10.01%100.00%

    2) add a calculated column in your table:

     

    Year = YEAR(TableName[Orderdate])

     

    3) plot a matrix visual with necessary columns and three measures like:

     

    Revenue2 = 
    SUMX(
        FILTER(
            TableName,
            TableName[Margin%]<=MAX(Range[MAX])
                &&TableName[Margin%]>=MAX(Range[MIN])
        ),
        TableName[Revenue]
    )
    
    OrderCount = 
    COUNTROWS(
        FILTER(
            TableName,
            TableName[Margin%]<=MAX(Range[MAX])
                &&TableName[Margin%]>=MAX(Range[MIN])
        )
    )
    
    RevenueDiff = 
    VAR _year  = MAX(TableName[Year])
    RETURN
    CALCULATE(
        [Revenue2],
        TableName[Year] = _year
    )
    -
    CALCULATE(
        [Revenue2],
        TableName[Year] = _year -1
    )

     

     

     

     

    it worked like: