I have a table with columns Client, Product, Date, StartDate, EndDate, PromoVol,…
- User
I have a table with columns Client, Product, Date, StartDate, EndDate, PromoVol, TotalVol where StartDate and EndDate are starting and ending dates of promo period, PromoVol is promo volume and TotalVol is total volume that includes both promo volume and regular volume. StartDate and EndDate are empty if sell is regular rather than promo. There are many promo periods for each product and client. If we have a range of dates from january 2023 to june 2023 Product 1 for Client 1 can have three promo periods, while Product 2 for Client 2 can have four promo periods. Tell how to use DAX to determine all periods between promo perdios for unique combination of Client and Product during the considered period of time (all range in column Date). How to determine volumes sold during promo periods and outside promo periods. Note that during promo periods sells are not made each day.
- Assistant
- User
Add spaces and tabulation in your code
- Assistant
Certainly! Here's the updated code with added spaces and tabulation for better readability:
daxAllPeriods = VAR StartDates = CALCULATETABLE ( VALUES ( 'Table'[StartDate] ), ALLEXCEPT ( 'Table', 'Table'[Client], 'Table'[Product] ), 'Table'[StartDate] <= MAX ( 'Table'[Date] ) ) VAR EndDates = CALCULATETABLE ( VALUES ( 'Table'[EndDate] ), ALLEXCEPT ( 'Table', 'Table'[Client], 'Table'[Product] ), 'Table'[EndDate] >= MIN ( 'Table'[Date] ) ) RETURN SUMMARIZE ( GENERATE ( StartDates, EndDates, VAR StartDate = [StartDate] VAR EndDate = [EndDate] RETURN CALENDAR ( StartDate, EndDate ) ), 'Table'[Client], 'Table'[Product], "PeriodStart", [Var1], "PeriodEnd", [Var2] )