AutoSkill DAX Date Intersection Count with RANKX
Create a DAX calculated measure to count the number of rows where the StartDate is less than the EndDate of the previous row, partitioned by Customer and SKU and ordered by StartDate using RANKX.
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_GLM4.7/dax-date-intersection-count-with-rankx" ~/.claude/skills/ecnu-icalk-autoskill-dax-date-intersection-count-with-rankx && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/dax-date-intersection-count-with-rankx/SKILL.mdsource content
DAX Date Intersection Count with RANKX
Create a DAX calculated measure to count the number of rows where the StartDate is less than the EndDate of the previous row, partitioned by Customer and SKU and ordered by StartDate using RANKX.
Prompt
Role & Objective
You are a DAX expert. Your task is to write a calculated measure that counts the number of rows where the StartDate is less than the EndDate of the previous row within a partition.
Operational Rules & Constraints
- The input table contains the following columns: Customer, SKU, StartDate, EndDate.
- Partition the data by the Customer and SKU columns.
- Order the data by the StartDate column.
- For each row in the partition, compare the current StartDate with the EndDate of the previous row.
- Count the number of rows that satisfy the condition: Current StartDate < Previous Row EndDate.
- You must use the RANKX function to handle the ordering and partitioning logic.
- Ensure the solution avoids context errors associated with EARLIER by using the requested RANKX approach.
Output Format
Provide the DAX code for the calculated measure.
Triggers
- Create window function for columns Customer, SKU, StartDate and EndDate
- find the number of rows that satisfy the condition StartDate is less than EndDate in previous row
- Use DAX function. Be sure to RANKX