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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
GreggPowell
Helper I
Helper I

How to extract every Nth row (record) in an existing table into a new table (Not Using Power Query)

How to extract every Nth row (record) in an existing table into a new table (Not Using Power Query).

 

I have a table where the data is pulled from SharePoint. One column in the table I created from a measure

New Column = Table[Measure]

So, that column does not show up when I transform the data - so I can't use Power Query.

I want to use Dax to extract every Nth row (in my case exactly, the 1st and then every 7th row) into a new table.

Is that even possible?

2 ACCEPTED SOLUTIONS

Had already added an index column. Problem is, I can't just tell it the row numbers I want to pick, because an API updates the data every day with a new row - so the whole thing must be automated.

I found this below - this is what I need to do.....

GreggPowell_0-1659803816724.png

Problem is with this Excel formula:

=FILTER(data,MOD(SEQUENCE(ROWS(data)),3)=0)

I can't find the equivelent Excel ROWS() function in DAX - so I can replicate this.

I think the ROWS() function is the only incompatibility between DAX and Excel - not sure though.

Can you (or anyone) help me rewrite this in DAX?

THANKS!!!
Gregg P.
Arizona USA

View solution in original post

I'm away from

a computer until Tuesday evening. Happy to build a demo at that point if no one gets there first.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

5 REPLIES 5
bcdobbs
Super User
Super User

Are you able to use power query to add an index column followed by a calculated column based on it using Number.Mod to your existing table?

 

You can then use Dax to create a calculated table along the lines of:

 

NewTable =
CALCULATETABLE (

 OriginalTable,

 ModColumn = 1

)

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Had already added an index column. Problem is, I can't just tell it the row numbers I want to pick, because an API updates the data every day with a new row - so the whole thing must be automated.

I found this below - this is what I need to do.....

GreggPowell_0-1659803816724.png

Problem is with this Excel formula:

=FILTER(data,MOD(SEQUENCE(ROWS(data)),3)=0)

I can't find the equivelent Excel ROWS() function in DAX - so I can replicate this.

I think the ROWS() function is the only incompatibility between DAX and Excel - not sure though.

Can you (or anyone) help me rewrite this in DAX?

THANKS!!!
Gregg P.
Arizona USA

What I was suggesting basically is that. Only difference is I'd suggest creating the modulo column in power query and then using the calculatetable to filter based on it.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

I'm away from

a computer until Tuesday evening. Happy to build a demo at that point if no one gets there first.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

You put me on the right track!

Thanks!

Here is what I did...

Extract_HR_PipeDrive_Deals = FILTER(ALL(HR_PipeDriveDeals_Running_Totals),HR_PipeDriveDeals_Running_Totals[Modulo]=6)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.