September 29, 2022

Get Members from the Security Group in Power Apps

We often come across a requirement wherein we need to fetch the information from the Security Group and need to display within Power Apps for Business Logic implementation.

Example:
Below is one of the Security Group created in Microsoft 365. Here, there are two members added to that Security Group.

In Power Apps, we need information about those two users.

Step 1: Open Power Apps Canvas App. First, we need to add Office 365 Groups Connector. For that, 
  1. Go to View Menu, and select Data sources.

  2. Search for “Office 365 Groups”. Select the highlighted one and add a connector to the App.

  3. Once the Connector is added, this will look like this.

Step 2:
  1. Open Power Apps screen and add a button.
  2. Write the following line of code for “On Select” event of the button.
     ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers("GroupID").value)  
  3. Here, MembersfromSG is the Name of the collection. Office365Groups.ListGroupMembers(“Group ID”) returns the information about all the members of that security group.

How can we find that Group ID for the Security Group?
  1. Open Azure Portal and search for Groups. This will open the following screen.
  2. Select your security group for more information.
  3. Copy Object Id. This is the Group ID. We can use this Group ID in the below formula. The formula will look like this.
 ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers("xxxxxxxx-1xxb-4x4b-xxxxxx").value)  

Step 3: Now, add Gallery Control and add Collection as a data source. This will show users in the Gallery.

Step 4: Now, let’s run the solution. This will show, User’s Display Name and User Principal Name.
You can check more properties of members returned by this collection from the executed collection.

Conclusion:
This is how we can get the Member Information using Office 365 Groups Connector in Power Apps.

If you have any questions you can reach out our SharePoint Consulting team here.

September 15, 2022

Filter Records based on Date and Time Condition in Power Apps

Overview:

Consider a scenario, where you are moving your Power Apps to the production environment and we only want to show records after our Production Launch!

Let’s say, Production Live happened at 01:00 PM then we need to show records created after 01:00 PM on that day. So, how can we achieve this? 

Solution:

We need to use the following Power Fx formula to achieve this!
  • DateValue
  • Time function with Hour, Minute, and Second

Consider the following example:
Below is the screenshot for List Items. We need to show records that are created only after “07/26/2021 01:00:00 PM”.
 

Go to your Power Apps and Add the following line of code to your Items Property of the Gallery.
 Filter(  
   Leaves,  
   (DateValue(  
     Text(  
       Created,  
       "[$-en-US]mm/dd/yyyy"  
     )  
   ) + Time(  
     Hour(Created),  
     Minute(Created),  
     Second(Created)  
   )) > (DateValue("07/26/2021") + Time(  
     Value(13),  
     0,  
     0  
   ))  
 )  

Here, we are comparing if the "Created" value from SharePoint List is greater than “07/26/2021 01:00:00 PM”.

As a result, we are getting the following outcome!
 

Conclusion:

Hope, this trick is helpful to you! Happy Power Apping!!

If you have any questions you can reach out our SharePoint Consulting team here.

September 8, 2022

How can we Pad 0 to Integer Values in Power BI?

Overview:

Sometimes we have a requirement, where we need to Pad “0” to our numeric value. There are multiple ways to implement this. But we will go with the simplest and easiest one! So, let’s get started!

Step 1:

This is our Sample Data Source, where we have Project ID, Project Name, and Hours column.

Now, we want to pad “0” before our Project ID column and need the end outcome like the following. So, how can we achieve this?

Step 2:

 - Open Model View of Power BI Desktop and select the “Project ID” column.
 - From Format, select “Custom”.
 - Under Custom Format provide, format as “00#” – This will suggest, from a 3-digit number, it will pad leading digits with “0”. 

Example: If the number is 9, it will show as “009”. If the number is 19 then it will show as “019”. This will show us the end outcome as below screen!

Conclusion:

This is how we can simply pad leading “0” before the number in Power BI. Isn’t that cool? Happy Reporting!

If you have any questions you can reach out our SharePoint Consulting team here.