Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am trying to create a calculated column "NextValidWW" which gets the next greater workweek partitioned by the ProjectID and TaskID. See below:
In SQL, I was able to achieve this by:
LEAD(StatusWW) OVER (
PARTITION BY TaskUID,
ProjectID
ORDER BY StatusWW
)
I found a post on reddit where it gives a very similar solution, but I am not getting my desired outcome:
TRY 1:
This works when the "next" greater work week is only greater than the StatusWW by 1 - but does not account for cases when the "next" greater work week could be greater than 1.
=CALCULATE(
VALUES(DCN_NextWW[StatusWW]),
ALLEXCEPT(DCN_NextWW, DCN_NextWW[ProjectID], DCN_NextWW[TaskUID]),
DCN_NextWW[StatusWW] = EARLIER(DCN_NextWW[StatusWW]) + 1 )
TRY 2:
This just gives me ERROR - which I understand it's returning all values that are greater than StatusWW - not just the "next" greater value
=CALCULATE(
VALUES(DCN_NextWW[StatusWW]),
ALLEXCEPT(DCN_NextWW, DCN_NextWW[ProjectID], DCN_NextWW[TaskUID]),
DCN_NextWW[StatusWW] > EARLIER(DCN_NextWW[StatusWW]))
It seems like TRY 2 could use more conditions where [StatusWW] < the next [StatusWW] but I am not sure how to do that in DAX.. there is no NEXT() function that I am aware of
Solved! Go to Solution.
Found a solution on another community post
CALCULATE(
MIN(DCN_NextWW[StatusWW]),
FILTER(
DCN_NextWW,
DCN_NextWW[StatusWW] > EARLIER(DCN_NextWW[StatusWW]) && (DCN_NextWW[ProjectID] = EARLIER(DCN_NextWW[ProjectID]) && DCN_NextWW[TaskUID] = EARLIER(DCN_NextWW[TaskUID]))))
Found a solution on another community post
CALCULATE(
MIN(DCN_NextWW[StatusWW]),
FILTER(
DCN_NextWW,
DCN_NextWW[StatusWW] > EARLIER(DCN_NextWW[StatusWW]) && (DCN_NextWW[ProjectID] = EARLIER(DCN_NextWW[ProjectID]) && DCN_NextWW[TaskUID] = EARLIER(DCN_NextWW[TaskUID]))))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |