Forum Discussion

Radhika2605's avatar
Radhika2605
Helper II
5 years ago
Solved

Need help with a measure

I am trying to find out if any sale has been lost or not due to out of stock products and have created a measure for it but when I try to visualize this measure in a table then it first lists all the...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Radhika2605 

    I think this problem should be caused by your data model. Please check whether there are some products out of the "Store ID" list. Your calculate logic is that [Total Stock On Hand] = 0 && [Average Units Sold Legit] > 0 return "Sale Lost", others return  "No Loss".

    In Power BI, the blank value will be recognized as 0. So  [Total Stock On Hand] = 0 && [Average Units Sold Legit] = 0 will return "No Loss" like result in your Screenshot. 

    Here I will give you two advices.

    1. Result is all right, you can remove blank store ids in filter field.

    2. Update your measure code.

     

    Lost sale? =
    IF (
        [Total Stock On Hand] = BLANK ()
            && [Average Units Sold Legit] = BLANK (),
        BLANK (),
        IF (
            [Total Stock On Hand] = 0
                && [Average Units Sold Legit] > 0,
            "Sale Lost",
            "No Loss"
        )
    )

     

    Best Regards,
    Rico Zhou

     

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

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Radhika2605 

    Due to I don't know the details about your data model, I could only give you some advices.

    I think there should be a table have Product column and Store column. In this table, there shoule be some products with Store ID which is out of the "Store ID" list. Then you relate this table with other tables which have Product column or Store column.

     

    Best Regards,
    Rico Zhou

     

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