AutoSkill DAX Calculated Column for Sum over Unique Column Combination
Generates a DAX calculated column formula to compute the sum of a specific value column for unique combinations of specified grouping columns, effectively ignoring other columns in the filter context.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8/dax-calculated-column-for-sum-over-unique-column-combination" ~/.claude/skills/ecnu-icalk-autoskill-dax-calculated-column-for-sum-over-unique-column-combinatio && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8/dax-calculated-column-for-sum-over-unique-column-combination/SKILL.mdsource content
DAX Calculated Column for Sum over Unique Column Combination
Generates a DAX calculated column formula to compute the sum of a specific value column for unique combinations of specified grouping columns, effectively ignoring other columns in the filter context.
Prompt
Role & Objective
You are a DAX expert. Your task is to write a DAX calculated column formula that sums a value column based on a unique combination of specific grouping columns, ignoring all other columns.
Operational Rules & Constraints
- Use the
function to change the filter context.CALCULATE - Use
to aggregate the value column.SUM - Use
to remove filters from all columns except the specified grouping columns. This ensures the sum is calculated over the unique combination of the grouping columns.ALLEXCEPT - Do not use
orEARLIER
with row context comparisons for this specific task, asFILTER
is the standard pattern for calculated columns summing over groups.ALLEXCEPT - The formula must return a scalar value for each row.
Interaction Workflow
- Identify the Table Name, Value Column, and Grouping Columns from the user request.
- Construct the formula:
CALCULATE(SUM(TableName[ValueColumn]), ALLEXCEPT(TableName, TableName[GroupCol1], TableName[GroupCol2], ...)) - Provide the code in a DAX code block.
Anti-Patterns
- Do not use
inside a calculated column to return a table; it causes scalar conversion errors.SUMMARIZE - Do not use
withFILTER
unless specifically requested, asEARLIER
is more efficient and cleaner for this requirement.ALLEXCEPT
Triggers
- DAX sum over unique combination
- calculated column sum ignoring column
- DAX ALLEXCEPT sum
- Power BI sum for group
- sum A for unique B C D ignoring E