Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

Little help with my report

Received Response
1
Views
5
Comments
Smakosh
Smakosh Rank 2 - Community Beginner

Hello! It will be nice to someone help me with my report or give same ideas. I want get in the results 'Product name' and how many days his quantity=0. For example I have this table

pastedImage_0.png

So I want to see:

pastedImage_1.png

Period is not necessary.

PS. I dont want you do this for  me, if you give me some tip it will be Okey.

Answers

  • Thomas Dodds
    Thomas Dodds Rank 8 - Analytics Strategist

    logical column with a 1 or 0 based on the criteria of quantity by day ... then sum up the new logical column over time ...

  • Smakosh
    Smakosh Rank 2 - Community Beginner

    Thanks Thomas I do like you say.

    Did you know how I can do this with Period. I must write question like this "show me period, product, quantity, and how many when day -1 quantity of produt was 1 OR NULL".

    For 0/1 column i do this formula:

    SUM((CASE WHEN "Dane"."Quantity"=0 THEN 1 WHEN "Dane"."Quantity">0 THEN 0   WHEN  "Dane"".Quantity)" IS NULL THEN 1 ELSE NULL END) BY "Product"."Product (name)"

    Result:

    pastedImage_0.png

  • Smakosh
    Smakosh Rank 2 - Community Beginner

    mistake:

    Did you know how I can do this with Period. I must write question like this "show me period, product, with quantity=0 or NULL, and how many days quantity was 0 or NULL when day -1 quantity of product was 1

  • Thomas Dodds
    Thomas Dodds Rank 8 - Analytics Strategist

    You are much better off 'architecting' a physical data structure that records the PRODUCT, DAY, QUANTITY, PREVIOUS DAY QUANTITY, LAST NON-ZERO DAY

    Have a row for EVERY Product and Day ... now you have no nulls only zeros for appropriate day.

    PREVIOUS DAY QUANTITY = LAG(QUANTITY) OVER(PARTITION BY PRODUCT ORDER BY DAY)

    LAST NON-ZERO DAY = (SELECT MAX(DAY) FROM TABLE WHERE PRODUCT = x.PRODUCT and QUANTITY > 0)

         ^ a sub-select in the row will get you this

  • Smakosh
    Smakosh Rank 2 - Community Beginner

    Thanks Thomas