Table Filter, Charts & Spreadsheets for Confluence Table Transformer Custom Transformation - use cases with advanced SQL queries Executing calculations with SQL Current: Calculating the number of distinct (unique) values by categories PDF Download PDF Download page Calculating the number of distinct (unique) values by categories. Current page All pages Calculating the number of distinct (unique) values by categories Use caseYou have a table (a macro outputting a table) containing multiple columns with text data.You need to calculate the number of distinct (unique) values by categories. For example, the number of unique customers in every segment. SolutionSwitch the page to the edit mode.Insert the Table Transformer macro and paste the table within the macro body.Select the macro and click Edit.Switch to the SQL query tab.Enter the following SQL query (select the functions depending on what you'd like to calculate): SELECT T1.'Segment', COUNT (DISTINCT (T1.'Customer Name')) AS 'Number of customers' FROM T* GROUP BY T1.'Segment' SQL Click Next.Define the table settings and view options if needed.Save the macro and the page. You can use FORMATWIKI function for the purposes of cell formatting. ×