Forum Discussion

TaariqHussain's avatar
1 year ago
Solved

Filter calculation in a measure

Good day All     I need assistance in calculating % of sales, example below   I have sales for 5 Items, however only 3 are on promotion, I am using the filter by list (Devscope) to filter my sal...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi TaariqHussain 

     

    Thank you very much bhanu_gautam for your prompt reply.

     

    For your question, here is the method I provided:

     

    Here's some dummy data

     

    “CapeTown_itemwisesales”

     

    “PromoList”

     

    Add a calculated column in the CapeTown_itemwisesales table to indicate whether an item is on promotion:

     

    IsPromo = IF(RELATED('PromoList'[ItemCode]) <> BLANK(), 1, 0)

     

    Create a measure to calculate the total promo sales:

     

    PromoSales = CALCULATE(SUM('CapeTown_itemwisesales'[TotalSales]), 'CapeTown_itemwisesales'[IsPromo] = 1)

     

    Create a measure to calculate the total sales:

     

    Measure TotalSales = SUM('CapeTown_itemwisesales'[TotalSales])

     

    Create a measure to calculate the percentage of promo sales versus total sales:

     

    PromoSalesPercentage = DIVIDE([PromoSales], [Measure TotalSales], 0)

     

    Here is the result.

     

     

    Regards,

    Nono Chen

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