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.
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.
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 |
---|---|
11 | |
10 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
13 | |
12 | |
11 | |
9 |