Skip to content

PowerAppsDarren/PowerFxSnippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

518 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Power Fx Snippets πŸ†

The world's most comprehensive collection of Power Fx code snippets for Microsoft Power Platform

GitHub stars GitHub issues GitHub PRs License

πŸŽ‰ What's New -- v2.0.0 Release

Major repository restructuring complete! The repository has been reorganized with a feature-first architecture for better navigation, discoverability, and developer experience.

πŸ“£ Read the full v2.0.0 Announcement | πŸ“‹ Release Notes

βœ… New Structure (9 Categories)

Category Description Highlights
πŸ“± app-lifecycle/ App initialization & lifecycle Named formulas, OnStart, OnError
🎨 ui-controls/ Control-specific snippets Gallery, buttons, inputs, charts
🎭 ui-patterns/ Reusable UI patterns Dialogs, menus, theming, components
🌈 visual-assets/ Visual resources SVGs, icons, colors, fonts, emojis
πŸ“Š data-operations/ Data & transformations Sample data, JSON, geocoding
πŸ”§ functions/ Functions & utilities UDFs, algorithms, string manipulation
πŸ”— integrations/ External services Office 365, Power Automate connectors
πŸŽ“ learning/ Educational content Tutorials, certification, best practices
🧰 utilities/ Tools & templates Validation scripts, templates

πŸ†• January 2026 Highlights

  • 468 markdown files with standardized structure
  • YAML frontmatter on all snippets for searchability
  • Table of Contents auto-generated in all files
  • History sections tracking changes in every file
  • GitHub Actions for automated snippet validation and weekly link checking
  • Unit test coverage for all repository tools (validator, index generator, migration helper)
  • Issue & PR templates for consistent contributions
  • PRODUCT-INDEX.md -- Browse snippets by Power Platform product
  • MIGRATION-GUIDE.md -- Find where your old bookmarks moved

πŸ“‹ View Migration Details | πŸ” Browse by Product

πŸš€ Quick Start

New to Power Fx? Start here:

Copy-Paste Code Examples

1. Detect if the app is running in Studio (edit) mode:

// Named formula -- place in App.Formulas
fxIsInStudioMode = StartsWith(Host.Version, "PowerApps-Studio");

Source: app-lifecycle/formulas/expressions/boolean-is-in-studio-mode.md

2. Alternating row colors (zebra striping) in a Gallery:

// Set TemplateFill on your Gallery control
If(
    Mod(ThisItem.OrderNumber, 2) = 0,
    Color.White,
    ColorFade(App.Theme.Colors.Lighter80, 50%)
)

Source: ui-controls/gallery/styling/alternating-row-colors.md

3. Convert a Color value to its hex string:

// User-defined function -- place in App.Formulas
fxGetHexFromColor(ColorValue: Color): Text = Left(
    Substitute(
        JSON(ColorValue, JSONFormat.Compact),
        """",
        ""
    ),
    7
);

Source: ui-patterns/theming/Theming.md

4. Random screen transition effect (UDF):

// User-defined function -- place in App.Formulas
fxRandomScreenTransition(): Text =
    With(
        { RandomNumber: RandBetween(1, 5) },
        Switch(
            RandomNumber,
            1, ScreenTransition.Cover,
            2, ScreenTransition.CoverRight,
            3, ScreenTransition.Fade,
            4, ScreenTransition.UnCover,
            5, ScreenTransition.UnCoverRight,
            ScreenTransition.None
        )
    );

Source: app-lifecycle/formulas/user-defined-functions/screen-transition-random.md

5. Parse JSON returned from a Power Automate flow:

UpdateContext(
    {
        locFlowResult: ParseJSON(MyFlow.Run(ThisItem.URL).response).value
    }
);
ClearCollect(
    colParsedData,
    ForAll(
        locFlowResult As MyRecord,
        {
            Name:        Text(MyRecord.Name),
            DisplayName: Text(MyRecord.DisplayName),
            Type:        Text(MyRecord.Type)
        }
    )
);

Source: data-operations/json/parsing-flows-json.md

πŸ“– Table of Contents

🎯 Core Categories

Category Description Quick Access
01-getting-started Entry point for new developers Hello World β€’ Common Patterns (Coming Soon)
02-app-architecture Application structure and lifecycle App Events β€’ Navigation
03-user-interface UI components and user experience Controls β€’ Themes
04-data-management Data operations and sources Data Sources β€’ Validation
05-business-logic Functions and calculations Functions β€’ Error Handling
06-integrations External services and APIs Microsoft 365 β€’ Azure
07-assets-and-media Visual assets and media Icons β€’ SVGs
08-advanced-patterns Expert techniques and architecture Custom Components β€’ Security
09-learning-resources Tutorials and educational content Tutorials β€’ Best Practices

πŸ› οΈ Repository Tools

πŸ”₯ Popular Snippets

Quick Wins (5 minutes or less)

Snippet Category Difficulty
Alternating Row Colors ui-controls / gallery Intermediate
Detect Studio Mode app-lifecycle / formulas Beginner
Color to Hex Conversion ui-patterns / theming Intermediate
Random Screen Transition app-lifecycle / formulas Beginner
Error Kinds Collection app-lifecycle / formulas Beginner

Advanced Solutions

Snippet Category Difficulty
Responsive Hero Cards Gallery ui-controls / gallery Intermediate
Get Manager Rollup (Org Hierarchy) integrations / Office 365 Advanced
Parse JSON from Power Automate Flows data-operations / json Intermediate
Proportional Value Calculator (UDF) app-lifecycle / formulas Intermediate
Microsoft Base Themes ui-patterns / theming Beginner

Browse all snippets: By Category | By Product | By Tag

🎯 How to Use This Repository

For Beginners

  1. Start with Getting Started category
  2. Browse by difficulty level (beginner/intermediate/advanced)
  3. Use the search function with keywords like "gallery", "form", or "SharePoint"

For Experienced Developers

  1. Jump directly to specific categories that match your needs
  2. Filter by tags and prerequisites
  3. Check related snippets for comprehensive solutions

For Teams

  1. Use Learning Resources for onboarding
  2. Implement Best Practices across projects
  3. Leverage Advanced Patterns for complex scenarios

πŸ” Search & Discovery

By Technology

By Use Case

🀝 Contributing

We welcome contributions! Here's how to get involved:

Ways to Contribute

  • πŸ“ Add Snippets: Share your Power Fx solutions
  • πŸ› Report Issues: Help improve existing content
  • πŸ’‘ Suggest Improvements: Propose new categories or features
  • πŸ“š Improve Documentation: Enhance guides and navigation

Getting Started

  1. Read our Contribution Guide
  2. Check existing Issues for ideas
  3. Fork the repository and create your branch
  4. Add your snippet with proper metadata
  5. Submit a pull request

Snippet Requirements

  • βœ… Metadata: Complete YAML front matter with title, description, category, tags, difficulty
  • βœ… Documentation: Clear explanation and usage examples
  • βœ… Code Quality: Well-formatted, commented Power Fx code
  • βœ… Testing: Include test scenarios where applicable

πŸ“Š Repository Stats

  • πŸ“ Categories: 9 main categories with 40+ subcategories
  • πŸ“„ Snippets: 500+ code examples and patterns
  • 🏷️ Tags: 200+ searchable tags for filtering
  • πŸ‘₯ Contributors: 50+ community members
  • ⭐ Stars: Your support helps grow the community!

🏒 About Power Fx

Power Fx is the low-code language that powers Microsoft Power Platform applications. It combines the familiarity of Excel formulas with the power of a programming language, enabling both citizen developers and professional developers to create sophisticated business applications.

Key Features:

  • πŸ“Š Excel-like syntax you already know
  • πŸ”§ IntelliSense and formula suggestions
  • 🌐 Cross-platform compatibility
  • ⚑ Real-time evaluation and debugging
  • πŸ”— Rich integrations with Microsoft 365 and Azure

πŸ“ž Support & Community

Get Help

Community Resources

❓ FAQ / Troubleshooting

Where did my old bookmark go? The repository was restructured in v2.0.0 (January 2026). All files were reorganized into 9 feature-based categories. See the Migration Guide for a complete mapping of old paths to new locations.

How do I find snippets by product (Canvas Apps, Model-Driven, Power Automate)? Check the Product Index which groups every snippet by the Power Platform product it applies to.

How do I contribute a snippet? Read the Contributing Guide for instructions on adding snippets, reporting issues, or proposing improvements. Every snippet needs YAML frontmatter, a clear description, and working Power Fx code.

Power Fx is not working the way I expected. Power Fx has important syntax differences from .NET, Excel, and JavaScript. Before debugging further, read the Power Fx Gotchas document -- especially the section on date/time formatting where m/mm is context-sensitive.

How do I validate my snippet before submitting? Run the snippet validator tool: python utilities/tools/snippet-validator.py your-file.md. This checks YAML frontmatter, required fields, and valid category/tag values.

πŸ“„ License

This repository is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Power Apps Community for inspiration and contributions
  • Microsoft Power Platform team for creating Power Fx
  • All Contributors who share their knowledge and expertise
  • You for being part of this amazing community!

⭐ Found this helpful? Star this repository to show your support!

🀝 Want to contribute? Check out our Contribution Guide to get started!

History

Date Author Changes
2026-01-29 Phase 6 v2.0.0 launch updates: enhanced Quick Start, Popular Snippets, FAQ, What's New
2026-01-27 Migration Initial TOC and history section added