Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

EARLIER function not working using DAX query

 

I need to get Next Row value, my steps are following:
1) Creating [RankIndex] column as RANKX grouping [IssueID] by 2 ASC columns [StartTime], [EndTime];
2) On this step using EARLIER function on [RankIndex] and [IssueID] column to get next row value.

 

Issue is that result is NULL, feeling is that EARLIER is not working on created column within variables table.

If I try to reproduce on dummy data in Report mode using the same steps in variables, then everything is working.
Please help, code:

let
Source = AnalysisServices.Database(
"xxxxxxxxxxxxxxxx",
"yyyyyyyyyyyyyyyy",
[Query="
DEFINE
var status_table = " & dax_query_OtherTables("USED_TABLE")
& "
var issue_table = SELECTCOLUMNS(" & #"dax_query_JiraIssue" & ", ""IDD"", VALUE([ID]), ""IssueKey"", [Key], ""IssueCurrentStatus"", [Status], ""IssueProjectKey"", [ProjectKey] )
var join_table = NATURALINNERJOIN(status_table, issue_table)
var table_add_columns = ADDCOLUMNS(
ADDCOLUMNS( join_table , ""IssuesFlaggedStatus"", CALCULATE(
CONTAINS(USED_TABLE, [Status], ""Impediment""),
FILTER( USED_TABLE, EARLIER(USED_TABLE[IssueID]) = USED_TABLE[IssueID])
),
""RankIndex"", IF( USED_TABLE[Status] <> ""Impediment"",
RANKX( FILTER(USED_TABLE, USED_TABLE[IssueID] = EARLIER( USED_TABLE[IssueID] ) && USED_TABLE[Status] <> ""Impediment""),
RANKX( FILTER(USED_TABLE, USED_TABLE[IssueID] = EARLIER( USED_TABLE[IssueID] ) && USED_TABLE[Status] <> ""Impediment""), USED_TABLE[StartTime], , DESC)
+ DIVIDE(
RANKX( FILTER(USED_TABLE, USED_TABLE[IssueID] = EARLIER( USED_TABLE[IssueID] ) && USED_TABLE[Status] <> ""Impediment""), USED_TABLE[EndTime], , DESC),
( COUNTROWS( FILTER(USED_TABLE, USED_TABLE[IssueID] = EARLIER( USED_TABLE[IssueID] ) && USED_TABLE[Status] <> ""Impediment"") ) + 1 )
)
)

)
), ""NextStatus"", CALCULATE(
MAX( USED_TABLE[Duration] ),
FILTER( USED_TABLE, EARLIER(USED_TABLE[IssueID]) = USED_TABLE[IssueID]
&& EARLIER( [RankIndex] )+1 = [RankIndex]
)
))
EVALUATE table_add_columns"
, Implementation="2.0"])
in
Source

 

image.png
Result:

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Unfortunatelly I do not have access SQL Server Management Studio as I am end user, who creates report on Cube data.

But it seems I solved an issue by doing ranking and finding next row value in power query.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@Anonymous,

When you use SQL Server Management Studio to connect to SSAS and implement the above query with variables, do you get expected result?


Regards,
Lydia

Anonymous
Not applicable

Unfortunatelly I do not have access SQL Server Management Studio as I am end user, who creates report on Cube data.

But it seems I solved an issue by doing ranking and finding next row value in power query.

Anonymous
Not applicable

@Anonymous,

Glad to hear the issue is solved, you can close this thread by accepting your reply as solution.

Regards,
Lydia

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.