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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Asish24
New Member

How to run multiple table generation commands at once?

I want to find the top 5 highest values of a column and generate an individual table for each value, like highest, 2nd highest, 3rd highest and so on....

As DAX doesn't have iteration functions, and multiple commands can't be executed in one go I am unable to do the above mentioned task.

 

I'm using the below mentioned command 5 times by changing the value of M from 1 to 5 to get the desired 5 tables, how to get them at once?

NewTable = TOPN(1, FILTER(ALL(TableName), RANKX(ALL(TableName) , TableName[ColumnName])= M),

TableName[ColumnName])

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks @lbendlin 

Hi, @Asish24 

Do you mean to automatically generate 5 separate calculated tables? There are no similar batch commands in Power BI for the time being. As you mentioned, make 5 copies of the formula, using one copy in each calculation table. If you need a table similar to the Cartesian product, you can use the formula provided by lbendlin, which will be very portable to generate a Cartesian product table. Something like this is shown in the figure below:

table1:

vjianpengmsft_1-1712727882923.png

 

table2:

vjianpengmsft_2-1712727895240.png

Use GENERATE():

vjianpengmsft_0-1712727830763.png

 

 

 

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks @lbendlin 

Hi, @Asish24 

Do you mean to automatically generate 5 separate calculated tables? There are no similar batch commands in Power BI for the time being. As you mentioned, make 5 copies of the formula, using one copy in each calculation table. If you need a table similar to the Cartesian product, you can use the formula provided by lbendlin, which will be very portable to generate a Cartesian product table. Something like this is shown in the figure below:

table1:

vjianpengmsft_1-1712727882923.png

 

table2:

vjianpengmsft_2-1712727895240.png

Use GENERATE():

vjianpengmsft_0-1712727830763.png

 

 

 

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

lbendlin
Super User
Super User

That's what GENERATE() is for.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.