Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone,
Today I was handled by my colleague her report! Unfortunately she was not here to explain some code for me and there is no documentation so I need some help to show me what does the code in RETURN block do?
@Table =
VAR _toPathsTable =
ADDCOLUMNS (
SELECTCOLUMNS (
'_G Vendors',
"VendorID", '_G Vendors'[USERNAME],
"@RFNo", SUBSTITUTE ( '_G Vendors'[POSITION], ",", "|" )
),
"@Length", PATHLENGTH ( [@RFNo] )
)
VAR T =
ADDCOLUMNS (
_toPathsTable,
"@Cumulative", SUMX ( FILTER ( _toPathsTable, [VendorID] <= EARLIER ( [VendorID] ) ), [@Length] )
)
RETURN
ADDCOLUMNS (
SELECTCOLUMNS (
ADDCOLUMNS (
GENERATESERIES ( 1, SUMX ( T, [@Length] ) ),
"Cumulative", MINX ( FILTER ( T, [@Cumulative] >= [Value] ), [@Cumulative] )
),
"VendorID", MAXX ( FILTER ( T, [@Cumulative] = [Cumulative] ), [VendorID] ),
"RF Combined", MAXX ( FILTER ( T, [@Cumulative] = [Cumulative] ), [@RFNo] ),
"RF Count", 1 + [Cumulative] - [Value]
),
"RFNo", TRIM(PATHITEM( [RF Combined], [RF Count] ))
)
- Here are some snippet data for each temporary table:
_toPathsTable returned data:
The T table is added Cumulative column base on VendorID
But the RETURN block I have no idea why she use GENERATESERIES function also the "RF Combined" and "RF Count" are disapeared from the returned data:
Many thanks for any help
The purpose of the RETURN block in the provided DAX (Data Analysis Expressions) code is to generate a new table as the output of the entire DAX query. Let's break down the RETURN block and its purpose:
GENERATESERIES Function:
Transformation and Filtering:
SELECTCOLUMNS and ADDCOLUMNS:
Transformation of RF Combined and RF Count:
Final Output:
In summary, the RETURN block is constructing a new table based on the previously defined tables and calculations. It seems to be transforming the cumulative path lengths and combining them with specific vendor IDs and RF numbers, resulting in a structured output.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |