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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
XaviOV
Helper V
Helper V

Generate a loop

Good morning,

 

I want to generate a loop like this with the following information:

XaviOV_1-1616582262006.jpeg

 

 

list=[]

i=1
while i<5:

     if #pallets[i]<#huecos[i]:

         list=list+LETRA[i]

    i=i+1

return list

 

 

 

1 ACCEPTED SOLUTION

Hi, @XaviOV 

According to your follow-up, I can understand your logic now, I think you can achieve this using the calculated table in Power BI, you can try my step:

Go to the table tool, create a new table like this:

v-robertq-msft_0-1617071923964.png

List =

SELECTCOLUMNS(

    FILTER(ALL('Table'),[#pallets]<[#huecos]),

    "LETRA",[LETRA])

 

Then you can get the expected list:

v-robertq-msft_1-1617071923967.png

The list will also be updated with the change of the dataset.

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

7 REPLIES 7
v-robertq-msft
Community Support
Community Support

Hi, @XaviOV 

According to your IF formula, I can’t clearly understand what you want to get. I’m wondering what does “LETRA[i]” mean? Because the column [LETRA] is “Text” type and it can’t be used to calculate with a number. Would you like to add a column to display your expected result manually?

v-robertq-msft_0-1616747769407.png

 

 

Best Regards,

Community Support Team _Robert Qin

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

Hi @v-robertq-msft 

What we want is to return a composite list with some rows of the lletra column. These rows will be all those that fulfill the condition that we have put. In this particular case it should return us: C and E.

Regards,
 
Xavi

Hi, @XaviOV 

According to your follow-up, I can understand your logic now, I think you can achieve this using the calculated table in Power BI, you can try my step:

Go to the table tool, create a new table like this:

v-robertq-msft_0-1617071923964.png

List =

SELECTCOLUMNS(

    FILTER(ALL('Table'),[#pallets]<[#huecos]),

    "LETRA",[LETRA])

 

Then you can get the expected list:

v-robertq-msft_1-1617071923967.png

The list will also be updated with the change of the dataset.

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

amitchandak
Super User
Super User

@XaviOV ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak ,

There is a screen shot.


test_pbi.png

Regards,

 

Xavi

@XaviOV , Still not clear.  You create first column using generateseries , rest need to come from that

 

generateseries(1,5)

 

https://docs.microsoft.com/en-us/dax/generateseries-function

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi, @amitchandak 

I want transalate this formula to DAX

list=[]

i=1
while i<5:

     if #pallets[i]<#huecos[i]:

         list=list+LETRA[i]

    i=i+1

return list


Regards,

Xavi



Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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