Forum Discussion

Jos13's avatar
Jos13
Icon for Helper III rankHelper III
6 years ago
Solved

Distribute sales to filtered values

Hi All, I have the following table. Here the total sales by all customers is 32. I will have a dropdown, in that only 3 customers(Customer1, 2 & 3) are included(Customer4 & 5 are excluded). W...
  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    6 years ago

    Hi Jos13 ,

     

    The measure Total doesn’t summarize, it is based on the calculation logic of each row.

     

    If you want to get the correct total, we suggest to create a calculate column like this.

     

    Column = 
    var _C4_C5 = CALCULATE(SUM('Table'[Sales]),FILTER(ALL('Table'),'Table'[Customer] in {"Customer 4","Customer 5"} && 'Table'[Date]=EARLIER('Table'[Date])))
    var _avg = _C4_C5 / 3
    return
    'Table'[Sales] + _avg

     

     

     

    But if you want to show the Total sales of each customer using a bar chart, you can try this Measure.

     

    Measure = 
    VAR _Total123 =
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            ALLSELECTED ( 'Table' ) )
    VAR _Total45 =
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            ALL ( 'Table' )
        ) -_Total123
    VAR _count =
        CALCULATE ( DISTINCTCOUNT ( 'Table'[Customer] ), ALLSELECTED('Table') )
    VAR _sum_sales =
        SUM ( 'Table'[Sales] )
    RETURN
    _Total45 / _count + _sum_sales

     

     

    The measure only displays the correct value in the current context.

     

    If you have any question, please kindly ask here and we will try to resolve it.

    BTW, pbix as attached.

     

    Best regards,

     

    Community Support Team _ zhenbw

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.