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

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

Reply
Davpek
Frequent Visitor

Count of values between specific rows in one column

Hello to all,

I need some help for transforming a simple table. We are getting a table from an automation and aren´t able to change the structure in the datasource, so we have to do it in Power BI.
It´s a table with one Column like you can see below:
We need to count the values between the Project´s. The value format is text and they have allways the value "value" (for example).
Is there a way to transform it to multiple project columns? The "Project cells" have alaways the same Text and it allaways the same number of projects cells, but the count of values between is different.

Has anyone an idea how we can count the values between or transform it to multiple columns by project?

Thank you very much!

Column1

Project 1
Value
Value
Value
Project 2
Value
Value
Value
Value
Project 3
Value
Value
Value
Value
Value
Project 4
Value
Value
Value
2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Table.Group: Exploring the 5th element in Power BI and Power Query – The BIccountant

 

Here's something to get you started

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKz0pNLlEwVIrViVYKS8wpTcXJgqk1IkItpi5jknRh6jchpDYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Column1"}, {{"Count", each Table.RowCount(_), Int64.Type}},GroupKind.Local,(x,y)=>Number.From(x<>y))
in
    #"Grouped Rows"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

 

Please provide a more detailed explanation of what you are aiming to achieve. Please show the expected outcome.

View solution in original post

Anonymous
Not applicable

Hi @Davpek ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. 

1. Transform the data as below screenshot in Power Query Editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKz0pNLlEwVIrViVYKS8wpTcXJgqk1IkItpi5jknRh6jchpDYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Conditional Column" = Table.AddColumn(Source, "Projects", each if Text.Contains([Column1], "Project") then [Column1] else null),
    #"Filled Down" = Table.FillDown(#"Added Conditional Column",{"Projects"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each not Text.Contains([Column1], "Project")),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Column1", "Values"}})
in
    #"Renamed Columns"

yingyinr_0-1651715226294.png

2. Create a table visual with the settings in below screenshot

yingyinr_1-1651715316414.png

If the above one can't help you get the desired result, please provide more sample data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

3 REPLIES 3
Davpek
Frequent Visitor

Thank you very much. This worked for me!👍

Anonymous
Not applicable

Hi @Davpek ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. 

1. Transform the data as below screenshot in Power Query Editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKz0pNLlEwVIrViVYKS8wpTcXJgqk1IkItpi5jknRh6jchpDYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Conditional Column" = Table.AddColumn(Source, "Projects", each if Text.Contains([Column1], "Project") then [Column1] else null),
    #"Filled Down" = Table.FillDown(#"Added Conditional Column",{"Projects"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each not Text.Contains([Column1], "Project")),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Column1", "Values"}})
in
    #"Renamed Columns"

yingyinr_0-1651715226294.png

2. Create a table visual with the settings in below screenshot

yingyinr_1-1651715316414.png

If the above one can't help you get the desired result, please provide more sample data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

lbendlin
Super User
Super User

Table.Group: Exploring the 5th element in Power BI and Power Query – The BIccountant

 

Here's something to get you started

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKz0pNLlEwVIrViVYKS8wpTcXJgqk1IkItpi5jknRh6jchpDYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Column1"}, {{"Count", each Table.RowCount(_), Int64.Type}},GroupKind.Local,(x,y)=>Number.From(x<>y))
in
    #"Grouped Rows"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

 

Please provide a more detailed explanation of what you are aiming to achieve. Please show the expected outcome.

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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 Kudoed Authors