cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Helper V

## Generate a loop

Good morning,

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

list=[]

i=1
while i<5:

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

list=list+LETRA[i]

i=i+1

return list

1 ACCEPTED SOLUTION
Community Support

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:

``````List =

SELECTCOLUMNS(

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

"LETRA",[LETRA])``````

Then you can get the expected list:

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

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.

7 REPLIES 7
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?

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.

Helper V
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
Community Support

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:

``````List =

SELECTCOLUMNS(

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

"LETRA",[LETRA])``````

Then you can get the expected list:

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

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.

Super User

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

Helper V

Hi @amitchandak ,

There is a screen shot.

Regards,

Xavi

Super User

@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

Helper V

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

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.