@fiddlerx
It seems like you are trying to build a progress bar in Power Apps based on a SharePoint list,
where you want to show the percentage of "Completed" tasks compared to the total number of tasks.
Here is some way you can try, to set global variables and use them to calculate the width of your progress bar:
Set global variables
You seem to be on the right track in terms of using global variables.
You can use the Set function in Power Apps to set global variables.
To get the count of each status, you can use the Filter function to filter your list based on status and then use CountRows to get the count. Here's how you might do it:
ClearCollect(SharePointList, [Your SharePoint Data Source]);
Set(varTotalCount, CountRows(SharePointList));
Set(varNotStartedCount, CountRows(Filter(SharePointList, Status = "Not started")));
Set(varInProgressCount, CountRows(Filter(SharePointList, Status = "In progress")));
Set(varCompletedCount, CountRows(Filter(SharePointList, Status = "Completed")));
Please replace [Your SharePoint Data Source] with your actual SharePoint data source name.
Or preferably, just do it on the data source directly, let's suppose it's called SharePointList
Set(varNotStartedCount, CountRows(Filter(SharePointList, Status = "Not started")));
Set(varInProgressCount, CountRows(Filter(SharePointList, Status = "In progress")));
Set(varCompletedCount, CountRows(Filter(SharePointList, Status = "Completed")));
Use these variables to get the width
To calculate the width of the rectangle, you need to find the proportion of "Completed" tasks compared to the total number of tasks. You can then multiply this ratio by the maximum width of your rectangle. Assuming maxWidth is the maximum width of the rectangle:
Set(rectangleWidth, (varCompletedCount/varTotalCount)*maxWidth);
Display the progress bar
In your rectangle's width property, simply set it as rectangleWidth.
Make a note that this solution assumes that the Status field in your SharePoint list is a text field.
If it's actually a Choice field, you may need to adjust your code slightly to accommodate that.
See if it helps @fiddlerx