Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

CustomerSKUDate = VAR addtable = GENERATE( SUMMARIZE(CustomerSKUShareMonth,…

  1. User

    Customer_SKU_Date = VAR add_table = GENERATE( SUMMARIZE(Customer_SKU_Share_Month, Customer_SKU_Share_Month[Customer Code], Customer_SKU_Share_Month[SCU Code], Customer_SKU_Share_Month[StartDate], Customer_SKU_Share_Month[EndDate]), VAR StartDate = Customer_SKU_Share_Month[StartDate] VAR EndDate = Customer_SKU_Share_Month[EndDate] RETURN ADDCOLUMNS( CALENDAR(StartDate, EndDate), "Customer", Customer_SKU_Share_Month[Customer Code], "SKU", Customer_SKU_Share_Month[SCU Code] ) ) RETURN SUMMARIZE(add_table,[Customer],[SKU],[Date])

    I neede to add a filter that Customer_SKU_Share_Month[Type] = X to create the table only for those rows. How to modify that?

  2. Assistant

    To add a filter to only include rows where Customer_SKU_Share_Month[Type] is equal to "X", you can modify the code as follows:

    Customer_SKU_Date = 
    VAR add_table = 
        GENERATE(
            SUMMARIZE(
                FILTER(
                    Customer_SKU_Share_Month,
                    Customer_SKU_Share_Month[Type] = "X"
                ),
                Customer_SKU_Share_Month[Customer Code],
                Customer_SKU_Share_Month[SCU Code],
                Customer_SKU_Share_Month[StartDate],
                Customer_SKU_Share_Month[EndDate]
            ),
            VAR StartDate = Customer_SKU_Share_Month[StartDate]
            VAR EndDate = Customer_SKU_Share_Month[EndDate]
            RETURN
            ADDCOLUMNS(
                CALENDAR(StartDate, EndDate),
                "Customer", Customer_SKU_Share_Month[Customer Code],
                "SKU", Customer_SKU_Share_Month[SCU Code]
            )
        )
    RETURN
        SUMMARIZE(add_table, [Customer], [SKU], [Date])
    

    In the above code, we added a FILTER function inside the SUMMARIZE function to filter only rows where Customer_SKU_Share_Month[Type] is equal to "X". Then, this filtered table is used in the GENERATE function to create the add_table variable.

    Note: Replace "X" with the appropriate value for the Type that you want to filter on.