Forum Discussion
KimGriso
11 months agoNew Member
Customer buying every year
Hi there, I am new learner and I am stuggling on trying to find out revenue from customers buying products every year. Could someone help me with my senario please? For example below table is s...
- 11 months ago
Hi KimGriso
This is a measure only approach:
Customer Sales with all years = VAR YearsWithDupes = // Build a table of all order dates and customers, with a computed "Year" column SUMMARIZE ( ALL ( 'Table' ), // remove filters, work over entire table 'Table'[Order Date], 'Table'[Customer Name], "Year", YEAR ( 'Table'[Order Date] ) ) VAR AllYears = // Count how many distinct years exist in the whole table COUNTROWS ( GROUPBY ( YearsWithDupes, [Year] ) ) RETURN SUMX ( FILTER ( // Build a per-customer table: one row per customer with sales and year count SUMMARIZECOLUMNS ( 'Table'[Customer Name], "@amount", SUM ( 'Table'[Sales Amt] ), // total sales per customer "@CustomerYears", COUNTROWS ( GROUPBY ( FILTER ( YearsWithDupes, [Customer Name] IN VALUES ( 'Table'[Customer Name] ) // only that customer ), [Year] // group by year ) ) // count distinct years for that customer ), // Keep only customers whose distinct years match the overall distinct years [@CustomerYears] = AllYears ), [@amount] // sum the sales of the qualifying customers )There are other approaches in the attached pbix that requires a dedicated tables and helper columns in the fact table.
Performance difference amount these approaches is neglible with small tables but can be obvious otherwise especially for the approach above.
Anonymous
11 months agoNot applicable
Hi KimGriso ,
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you
Anonymous
11 months agoNot applicable
Hi KimGriso ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.