CustomerSKUDate = VAR addtable = GENERATE( SUMMARIZE(CustomerSKUShareMonth,…
- 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?
- 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
FILTERfunction inside theSUMMARIZEfunction to filter only rows where Customer_SKU_Share_Month[Type] is equal to "X". Then, this filtered table is used in theGENERATEfunction to create the add_table variable.Note: Replace "X" with the appropriate value for the Type that you want to filter on.