This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hi all
I am unfamiliar with SQL script and have a set of data where the following has been used "
@row_number := CASE
WHEN @prev_id = t1.id THEN @row_number + 1
Add an Index Column:
Add a Custom Column for Row Number:
= Table.AddColumn(PreviousStep, "RowNumber", each if [ID] = try PreviousStep{[Index]-2}[ID] otherwise null then [Index] - try PreviousStep{[Index]-2}[Index] otherwise 1)
= Table.Group(PreviousStep, {"ID"}, {{"MaxCount", each List.Max([RowNumber]), type number}})
= Table.Join(MainQuery, "ID", AggregatedData, "ID")
= Table.AddColumn(PreviousStep, "FinalMinutes", each [Minutes] / [MaxCount])
@row_number := CASE
WHEN @prev_id = t1.id THEN @row_number + 1
Please provide the entire SQL - missing the ELSE and END statements.
AS max_counts ON J1.ID = max_counts.ID;
That is some rather advanced SQL. Can you confirm that this runs in SSMS?
I would not be surprised if things like
...
@row_number := CASE
WHEN @prev_id = t1.id THEN @row_number + 1
ELSE 1
END AS `COUNT`,
@prev_id := t1.id
...
would not be supported in Power Query's SQL connector (unless you declare it as Value.NativeQuery maybe).
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 31 | |
| 22 | |
| 15 |
| User | Count |
|---|---|
| 74 | |
| 61 | |
| 31 | |
| 31 | |
| 23 |