Case statement with two conditions

Hey!

 

I have a case statement below for inventory to create a pie graph. 

 

Case
WHEN `AVAILABLE_COUNT` <= 20 THEN 'Out of Stock'
WHEN `AVAILABLE_COUNT` >= 40 THEN 'Sufficient Stock'
Else 'Low levels'
End

 

The only problem is that I have 2 warehouses I included as filters. However, when the data populates it separates the two locations as different entity and counts it separately.

If warehouse A has inventory, but warehouse B has no inventory, then it counts for two status.

Even if both warehouses have inventory, it still counts as two status because of location.

I want to have the total inventory counted as one status in both warehouses. 

 

Sorry, if this is confusing. Let me know if you need any clarifications. 

What should include in this beast mode calcuation?

 

Thanks!

Comments

  • Can you show a sample of your data/scenario?

  • The Total should only be 149, but since there are two warehouses it counts as 298.

     

     

  • Anyone?

  • A way to go around the issue, but nto solve it as such, would be to combine the two warehouses using ETL then either create a separate DataSet or append it to the original and calling it Warehouse A+B in the Warehosue column.

     

    Not as clean as the ideal but would work in principle.

  • Could you show how I would do it in ETL. I am pretty new to this.

     

    Thanks!

  • I would suggest starting with the tutorials (Dataflows and Group by Function)  then but I will give you info on the function you need to use.

     

     

     

    The function is Group By

    1 Coiumn that identifies the grouping is Item_ID

    2 Name fo the new aggregated column can be Available Stock

    3 Column to aggegate the fill the new column is Available_Count

    4 How to aggegate column is Sum

     

     

    This will generate a table with to columns 

    Item_ID, each item will only come up once, 149 lines in total

    Available Stock, will have the combined count for each time.

     

    After that you can use the new table as a data set or combine it with the original.

    As I said it is not as clean as ideal but it will get you there. Ideally this would be done in beastmode but I cant think of a way to do it.