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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
thod
Helper I
Helper I

Count number of Power Query applied steps in Power BI

Hi,

I have gathered metadata from our Power BI tenant through the scanner API.

In this I have "let" expressions (power query advanced editor) from all semantic models and I want to count the number of applied steps in used for each table in these semantic models. Some examples of "let" expressions are:

No. 1 - One applied step:
 let
Source = Sql.Database(#"Server Prod - Dataplatform", #"Database Prod - SharedDimensions", [Query="SELECT [DW_SK_Brand]#(lf) ,[BrandId]#(lf) ,[Brand]#(lf) ,[BrandBeskrivelse]#(lf) FROM [DSO_SharedDimensions].[all].[DimBrand]"])
in
Source

 

No 2. - Two applied steps:
let
Source = Sql.Database(#"Server Prod - Dataplatform", #"Database Prod - SharedDimensions"),
dpa_FctBeregninger = Source{[Schema="all",Item="FctBeregninger"]}[Data]
in
dpa_FctBeregninger

No 3 - Three applied steps:
let
Source = Sql.Database(#"Server Prod - Dataplatform", #"Database Prod - SharedDimensions", [Query="SELECT [DW_SK_Produkt]#(lf) ,[ProduktID]#(lf) ,Produkt#(lf) ,Produktgruppe#(lf) ,[ProduktBeskrivelse]#(lf) ,[ProduktBeskrivelseENG]#(lf) FROM [DSO_SharedDimensions].[all].[DimProdukt]"]),
#"Filtered Rows" = Table.SelectRows(Source, each ([ProduktID] = 1000000 or [ProduktID] = 1000001)),
#"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"DW_SK_Produkt", Int64.Type}})
in
#"Changed Type"

So two sum up, I want a measure that calculates how many applied steps there is for each "let" expression in the dataset.

Br.,
Thomas

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@thod Simple enough. PBIX below sig.

 

Measure = 
    VAR __Text = MAX('Table'[Column1])
    VAR __Length = LEN(__Text)
    VAR __Replace = SUBSTITUTE( __Text, "," & UNICHAR(10), "" )
    VAR __NewLength = LEN(__Replace)
    VAR __Diff = __Length - __NewLength
    VAR __Result = DIVIDE( __Diff, 2 ) + 1
RETURN
    __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@thod Simple enough. PBIX below sig.

 

Measure = 
    VAR __Text = MAX('Table'[Column1])
    VAR __Length = LEN(__Text)
    VAR __Replace = SUBSTITUTE( __Text, "," & UNICHAR(10), "" )
    VAR __NewLength = LEN(__Replace)
    VAR __Diff = __Length - __NewLength
    VAR __Result = DIVIDE( __Diff, 2 ) + 1
RETURN
    __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,
Thank you very much. I had to modify your measure a tiny bit, as it for some reason included a lot of tables that is not a part of the data set with the result of one.
So the modified measure that works is:

measure =
VAR __Text =
    MAX ( 'Table'[Column1] )
VAR __Length =
    LEN ( __Text )
VAR __Replace =
    SUBSTITUTE ( __Text, "," & UNICHAR ( 10 ), "" )
VAR __NewLength =
    LEN ( __Replace )
VAR __Diff = __Length - __NewLength
VAR __Result =
    IF ( ISBLANK ( __Length ), BLANK (), DIVIDE ( __Diff, 2 ) + 1 )
RETURN
    __Result


Br,
thod

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors