cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
_kikilalaaa
Helper V
Helper V

How to fetch array data from SharePoint List to Power Apps

Hi all. I have a sharepoint list with table as follow.

 

 

StudentMarks 1Difference
A80 
B90 
C50 

 

The details for Marks 1  are already in SharePoint List.

"Difference" are not stored in the SharePoint List as it differs according to user who log in the system.It is calculated such as follow.

Let say I loggoed in as student A, I will compare my difference with Student B and Student C.

The formula is (Marks 1(A)- Marks 1(B)) and (Marks 1(A)- Marks 1(C)). So the answer should be like this:

 

StudentMarks 1Difference
A800
B90-10
C5030

 

Students and Difference would be displayed in Gallery in PowerApps. 

 

My question is, how do I get all the data for marks and do the calculation for each student?

Thank you for your help!

2 ACCEPTED SOLUTIONS

Accepted Solutions

@_kikilalaaa ,

Firstly typing error (now corrected) - should be a colon rather than a comma after wMarks at the top. If you want both fields, you could do this

With(
   {
      wMarks:
      LookUp(
         YourSPList,
         Student=varUserName
      )
   },
   AddColumns(
      YourSPList,
      "Difference",
      wMarks.'Marks 1' - 'Marks 1',
      "Student B",
      wMarks.Student
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Hi @_kikilalaaa ,

Here is a similar exercise done with a computer price test list I have which shows the price difference on every other device to the top one.

ComparePrices.png

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

 

 

View solution in original post

8 REPLIES 8
WarrenBelz
Super User III
Super User III

Hi @_kikilalaaa ,

I assume you have your user's name in the Student field? If so, put this at App OnStart

Set(varUserName,User().FullName)

Then this would be the Items of the Gallery as you have displayed

With(
   {
      wMarks:
	  LookUp(
         YourSPList,
         Student=varUserName
      ).'Marks 1'
   },
   AddColumns(
      YourSPList,
      "Difference",
      wMarks - 'Marks 1'
   )
)   

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

_kikilalaaa
Helper V
Helper V

dear @WarrenBelz , 

thank you for helping.

Can you explain a bit on this code?

_kikilalaaa_0-1611509978231.png

What should be the output for this? Because I want to show the student's Name and Difference but from this coding, I think it only show the difference.

Student is the column name right? 

 

As for now, I still got error with the function "With". It says that it has invalid argument.

 

Thanks again!

@_kikilalaaa ,

Firstly typing error (now corrected) - should be a colon rather than a comma after wMarks at the top. If you want both fields, you could do this

With(
   {
      wMarks:
      LookUp(
         YourSPList,
         Student=varUserName
      )
   },
   AddColumns(
      YourSPList,
      "Difference",
      wMarks.'Marks 1' - 'Marks 1',
      "Student B",
      wMarks.Student
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Hi again. I have tried your code but I need some clarification.

 

1) Do I need to create "Difference" column first in the SPList?

2) Based on your code, you identified the other student. But actually I might have more than 1 student to compare. How do i declare that?

 

I am thinking of not storing the compatibility rate in the SPList, instead it will just store in the PowerApps lie a variable and being displayed to user. I'm thinking of using collection to store the answer for the formula but I do not know how to start. 

 

Looking forward for your help! Thank youuu

Hi @_kikilalaaa ,

Here is a similar exercise done with a computer price test list I have which shows the price difference on every other device to the top one.

ComparePrices.png

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

 

 

View solution in original post

Hi @WarrenBelz ,

I did not get the "OtherDevice" part? Is it a column that you have already declared in the SPList, or new column that you have just declared? Can you elaborate more?

 

Thanks and stay safe!

@_kikilalaaa ,

It is a new column using AddColumns - you can call it whatever you like. It is simply the device selected in the gallery for display purposes in the second last column - you do not really need it if you have your TemplateFill set 

If(
   ThisItem.IsSelected,
   LightBlue,
   White
)

as you would then see what is being compared on both lines.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thank you so much. It helps me a lot!😁

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,031)