Stage 8 of 17

Stage 8 of 17

Build

Build the Software Licence Management Canvas Power App. 8 screens: Dashboard, Products, Agreements, Licence Details, Allocations, Renewals, New Allocation, and Compliance Report.

App OnStart — Global Variables and Collections

Why Are We Doing This?

App OnStart runs once when the app loads. Use it to load all data into collections and set global variables. Loading data here means every screen can use the collections without making repeated SharePoint calls — the app is faster and more responsive.

// Load all data into collections

ClearCollect(colProducts, Products);

ClearCollect(colSuppliers, Suppliers);

ClearCollect(colAgreements, Agreements);

ClearCollect(colAllocations, Allocations);

// Set permission variables

Set(varITEmails, ["tom.reeves@contoso.com", "james.okafor@contoso.com", "priya.mehta@contoso.com"]);

Set(varFinanceEmails, ["sandra.obi@contoso.com"]);

Set(varIsIT, User().Email in varITEmails);

Set(varIsFinanceOrIT, varIsIT Or User().Email in varFinanceEmails);

// Navigate to Dashboard

Navigate(scrDashboard);

Hardcoded Email Lists

Like DTOD-012, the permission email lists are hardcoded in App OnStart. If a new IT team member joins, Tom Reeves must update the formula and republish the app. This is documented as KE-003 in the Support stage. See IMP-002 for the dynamic membership improvement.

AnnualisedCost Calculation

The central calculation — used on every screen that shows cost

// AnnualisedCost formula (used in gallery items and KPI cards)

If(

ThisItem.BillingFrequency = "Monthly",

ThisItem.UnitCost * ThisItem.QuantityPurchased * 12,

If(

ThisItem.BillingFrequency = "Annual",

ThisItem.UnitCost * ThisItem.QuantityPurchased,

ThisItem.UnitCost * ThisItem.QuantityPurchased / 3

)

)

Verification examples from sample data

AGR-001 (M365, 300 licences, £15.90/month)£15.90 × 300 × 12 = £57,240/year
AGR-002 (Adobe, 25 licences, £624/year)£624 × 25 × 1 = £15,600/year
AGR-005 (GitHub, 50 licences, £1,200/3-year)£1,200 × 50 ÷ 3 = £20,000/year

QuantityAllocated and QuantityAvailable

These values are calculated in the Power App, not stored in SharePoint. Calculate them per agreement row in the gallery using a local variable or inline formula.

// In the gallery — per row calculation

// QuantityAllocated label Text property:

CountRows(Filter(colAllocations, Agreement.Id = ThisItem.ID, Status = "Active"))

// QuantityAvailable label Text property:

ThisItem.QuantityPurchased - CountRows(Filter(colAllocations, Agreement.Id = ThisItem.ID, Status = "Active"))

// QuantityAvailable colour (red if negative, amber if at threshold, green otherwise):

With(

{ qty: ThisItem.QuantityPurchased - CountRows(Filter(colAllocations, Agreement.Id = ThisItem.ID, Status = "Active")),

threshold: Max(1, Round(ThisItem.QuantityPurchased * 0.1, 0)) }

,

If(qty < 0, RGBA(220,38,38,1), If(qty <= threshold, RGBA(245,158,11,1), RGBA(34,197,94,1)))

)

Performance Note

Calling CountRows(Filter(colAllocations, ...)) for every row in the gallery can be slow if the Allocations list is large. For better performance, pre-calculate QuantityAllocated per agreement in App OnStart using a GroupBy expression and store it in a collection. This is covered in IMP-003.

Screen Build Steps

scrDashboard — Dashboard

  1. 1.Create a new screen named scrDashboard.
  2. 2.Add 5 KPI cards (rectangle + labels): Total Active Agreements, Total Annualised Spend, Expiring in 90 Days, Over-Allocated, Low Availability.
  3. 3.Total Active Agreements: CountRows(Filter(colAgreements, Status = "Active"))
  4. 4.Total Annualised Spend: Sum(Filter(colAgreements, Status = "Active"), If(BillingFrequency = "Monthly", UnitCost * QuantityPurchased * 12, If(BillingFrequency = "Annual", UnitCost * QuantityPurchased, UnitCost * QuantityPurchased / 3)))
  5. 5.Expiring in 90 Days: CountRows(Filter(colAgreements, Status = "Active", DateDiff(Today(), RenewalDate, Days) <= 90))
  6. 6.Over-Allocated: CountRows(Filter(colAgreements, Status = "Active", QuantityPurchased < CountRows(Filter(colAllocations, Agreement.Id = ID, Status = "Active"))))
  7. 7.Add a gallery: Agreements expiring in 90 days. Items: Filter(colAgreements, Status = "Active", DateDiff(Today(), RenewalDate, Days) <= 90). Sort by RenewalDate ascending.
  8. 8.Add a gallery: Over-allocated agreements. Items: Filter(colAgreements, Status = "Active"). Filter in gallery Visible: CountRows(Filter(colAllocations, Agreement.Id = ThisItem.ID, Status = "Active")) > ThisItem.QuantityPurchased.

scrProducts — Products

  1. 1.Create a new screen named scrProducts.
  2. 2.Add a gallery with Items: Filter(colProducts, (txtProductSearch.Text = "" Or Title in txtProductSearch.Text), (ddCategory.Selected.Value = "All" Or Category = ddCategory.Selected.Value))
  3. 3.Gallery columns: Title, Publisher, Category, active agreement count.
  4. 4.Add a Category dropdown (ddCategory) with choices: All, Productivity, Security, Development, Design, Finance, CRM, Project Management, Communication, Other.
  5. 5.Add a search text input (txtProductSearch).
  6. 6.Add a New Product button: Visible = varIsIT. OnSelect: NewForm(frmProduct); Navigate(scrNewProduct).
  7. 7.Gallery OnSelect: Set(varSelectedProduct, ThisItem); Navigate(scrProductDetails).

scrAgreements — Agreements

  1. 1.Create a new screen named scrAgreements.
  2. 2.Add a gallery with Items: Filter(colAgreements, (txtAgreementSearch.Text = "" Or Product.Value in txtAgreementSearch.Text), (ddAgreementStatus.Selected.Value = "All" Or Status = ddAgreementStatus.Selected.Value))
  3. 3.Gallery columns: Product name (Product.Value), Supplier name (Supplier.Value), QuantityPurchased, QuantityAllocated (calculated), QuantityAvailable (calculated, colour-coded), AnnualisedCost (Visible = varIsFinanceOrIT), RenewalDate, DaysToRenewal (colour-coded), Status badge.
  4. 4.Add a Status dropdown (ddAgreementStatus): All, Active, Pending Renewal, Under Review, Expired, Cancelled.
  5. 5.Add a search text input (txtAgreementSearch).
  6. 6.Add a New Agreement button: Visible = varIsIT.
  7. 7.Gallery OnSelect: Set(varSelectedAgreement, ThisItem); Navigate(scrLicenceDetails).

scrLicenceDetails — Licence Details

  1. 1.Create a new screen named scrLicenceDetails.
  2. 2.Header section: Product name (varSelectedAgreement.Product.Value), Supplier (varSelectedAgreement.Supplier.Value), Status badge, DaysToRenewal.
  3. 3.Compliance badge: If(varQtyAllocated > varSelectedAgreement.QuantityPurchased, "Over-Allocated", If(varQtyAllocated = 0, "Under-Utilised", "Compliant")). Colour: red / amber / green.
  4. 4.Set varQtyAllocated on screen OnVisible: Set(varQtyAllocated, CountRows(Filter(colAllocations, Agreement.Id = varSelectedAgreement.ID, Status = "Active")))
  5. 5.Set varAnnualisedCost on screen OnVisible using the AnnualisedCost formula.
  6. 6.Tab buttons: Overview, Allocations, History. Set(varLicenceTab, "Overview") etc.
  7. 7.Overview tab: all agreement fields. AnnualisedCost label Visible = varIsFinanceOrIT.
  8. 8.Allocations tab gallery: Filter(colAllocations, Agreement.Id = varSelectedAgreement.ID, Status = "Active"). Columns: AllocatedTo, Department, AllocatedDate, AllocatedBy.
  9. 9.History tab gallery: Filter(colAllocations, Agreement.Id = varSelectedAgreement.ID, Status = "Inactive"). Columns: AllocatedTo, Department, AllocatedDate, DeallocationDate.
  10. 10.New Allocation button: Visible = varIsIT. OnSelect: Set(varAllocationAgreement, varSelectedAgreement); Navigate(scrNewAllocation).
  11. 11.Deallocate button in Allocations gallery: Visible = varIsIT. OnSelect: Patch(Allocations, ThisItem, {Status: "Inactive", DeallocationDate: Today()}); Refresh(colAllocations).

scrAllocations — Allocations

  1. 1.Create a new screen named scrAllocations.
  2. 2.Gallery Items: Filter(colAllocations, Status = "Active", (ddDepartment.Selected.Value = "All" Or Department = ddDepartment.Selected.Value), (txtAllocationSearch.Text = "" Or AllocatedTo in txtAllocationSearch.Text))
  3. 3.Gallery columns: Product (via LookUp(colAgreements, ID = ThisItem.Agreement.Id).Product.Value), AllocatedTo, Department, AllocatedDate, AllocatedBy.
  4. 4.Department dropdown (ddDepartment): All, IT, Finance, Operations, HR, Marketing, Sales, Legal, Other.
  5. 5.Search text input (txtAllocationSearch).
  6. 6.Deallocate button in gallery: Visible = varIsIT.

scrRenewals — Renewals

  1. 1.Create a new screen named scrRenewals.
  2. 2.Gallery Items: SortByColumns(Filter(colAgreements, Status in ["Active", "Pending Renewal", "Under Review"], (ddRenewalFilter.Selected.Value = "All" Or DateDiff(Today(), RenewalDate, Days) <= Value(ddRenewalFilter.Selected.Value))), "RenewalDate", Ascending)
  3. 3.Gallery columns: Product, Supplier, RenewalDate, DaysToRenewal (colour-coded: ≤30 red, ≤90 amber, ≤180 blue, otherwise green), AnnualisedCost (Visible = varIsFinanceOrIT), Owner, Status.
  4. 4.Renewal filter dropdown (ddRenewalFilter): All, 30, 60, 90, 180.
  5. 5.Mark Under Review button: Visible = varIsIT. OnSelect: Patch(Agreements, varSelectedAgreement, {Status: "Under Review"}); Refresh(colAgreements).

scrNewAllocation — New Allocation Form

  1. 1.Create a new screen named scrNewAllocation.
  2. 2.Agreement dropdown (ddNewAgreement): Items = colAgreements. Default = varAllocationAgreement (pre-populated from scrLicenceDetails).
  3. 3.QuantityAvailable display: Set on ddNewAgreement OnChange: Set(varQtyAvailableOnForm, LookUp(colAgreements, ID = ddNewAgreement.Selected.ID).QuantityPurchased - CountRows(Filter(colAllocations, Agreement.Id = ddNewAgreement.Selected.ID, Status = "Active")))
  4. 4.Warning banner: Visible = varQtyAvailableOnForm <= 0. Text: "No licences available — purchase additional licences before allocating."
  5. 5.AllocatedTo text input (txtAllocatedTo).
  6. 6.AllocatedToEmail text input (txtAllocatedToEmail).
  7. 7.Department dropdown (ddNewDept).
  8. 8.AllocatedDate date picker: Default = Today().
  9. 9.AllocatedBy text input: Default = User().FullName.
  10. 10.Notes text area.
  11. 11.Save button: Disabled = varQtyAvailableOnForm <= 0. OnSelect: Patch(Allocations, Defaults(Allocations), {Title: ddNewAgreement.Selected.Product.Value & " — " & txtAllocatedTo.Text, Agreement: {Id: ddNewAgreement.Selected.ID, Value: ddNewAgreement.Selected.Title}, AllocatedTo: txtAllocatedTo.Text, AllocatedToEmail: txtAllocatedToEmail.Text, Department: ddNewDept.Selected.Value, AllocatedDate: dpAllocatedDate.SelectedDate, AllocatedBy: txtAllocatedBy.Text, Status: "Active", Notes: txtNotes.Text}); Collect(colAllocations, Last(Allocations)); Navigate(scrLicenceDetails).

scrComplianceReport — Compliance Report

  1. 1.Create a new screen named scrComplianceReport.
  2. 2.Screen Visible = varIsFinanceOrIT. If a non-Finance/IT user navigates here, show an access denied message.
  3. 3.Gallery Items: Filter(colAgreements, Status = "Active"). Sort by Product name.
  4. 4.Gallery columns: Product, Supplier, LicenceType, QuantityPurchased, QuantityAllocated (calculated), QuantityAvailable (calculated), ComplianceStatus (Compliant / Over-Allocated / Under-Utilised), AnnualisedCost.
  5. 5.ComplianceStatus colour: Over-Allocated = red, Under-Utilised = amber, Compliant = green.
  6. 6.Summary row: Total agreements, Compliant count, Over-Allocated count, Under-Utilised count.
  7. 7.Export button: Use html-to-image or Print() to allow the user to save the report as a PDF.

Stage Complete — What You Now Have

  • ✓App OnStart with 4 collections, permission variables, and navigation
  • ✓AnnualisedCost formula handling Monthly / Annual / 3-Year billing
  • ✓QuantityAllocated and QuantityAvailable calculated per row with colour coding
  • ✓8 screens: Dashboard, Products, Agreements, Licence Details, Allocations, Renewals, New Allocation, Compliance Report
  • ✓Compliance badge: Compliant / Over-Allocated / Under-Utilised
  • ✓New Allocation form with availability check and Save disabled when no licences available

Need more help with the concepts?

Visit DosToDigital for guides, templates, and deeper explanations.

DosToDigital
DToD Labs

Learn it. Build it. Make it work.

A DosToDigital Project

About DToD Labs

Practical technology learning for Microsoft 365 and Power Platform. Build real business solutions from real business problems.

Learn the concepts at DosToDigital. Put them into practice at DToD Labs.

DToD Labs provides practical learning projects for educational purposes. Microsoft services, interfaces, licensing and product capabilities change over time. Always check current Microsoft documentation and licensing before implementing a solution in a production environment. All organisations, business scenarios and data used in DToD Labs are fictional. Learners should not use confidential employer, customer or personal information when following DToD Labs exercises.

© 2026 DToD Labs — A DosToDigital Project