Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added KPI Sample #20

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
156 changes: 156 additions & 0 deletions samples/ifcolorconditions-function/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# If Value/Text Color Conditions - KPI Usecase


## Summary

Short summary on functionality and used technologies.

This PowerFX example shows how to leverage an IF statement, against Text or Values on the Fill property of a text label.
This can of course be used for conditional fonts, font weight, combining with dynamic variables and many more.

![KPI Values in a condition](assets/screenshotkpivalues.png)

* [If](#If)
* [Value](#Value)
* [Text](#Text)
* [Color](#Color)

## Applies to

* [Microsoft Power Fx](https://docs.microsoft.com/en-us/power-platform/power-fx/overview)

## Compatibility

![Power Apps Source File Pack and Unpack Utility 0.20](https://img.shields.io/badge/PSAopa-0.20-green.svg)

## Solution

Solution|Author(s)
--------|---------
Ifcolorconditions-function | [Author Name](Nathalie-:eenders) ([@NathLeenders](https://twitter.com/yourtwitterhandle))

## Version history

Version|Date|Comments
-------|----|--------
1.0|March 30, 2023|Initial release


## Prerequisites

No pre requisities needed for this app.

## Minimal Path to Awesome

* [Download](solution\KPIUsecases.msapp) the `.msapp` from the `solution` folder
* Use the `.msapp` file using **File** > **Open** > **Browse** within Power Apps Studio.


## Using the Source Code

You can also use the [Power Apps Source Code tool](https://github.com/microsoft/PowerApps-Language-Tooling) to the code using these steps:
* Clone the repository to a local drive
* Pack the source files back into `.msapp` file:
* [Power Apps Tooling Usage](https://github.com/microsoft/PowerApps-Language-Tooling)
* Use the `.msapp` file using **File** > **Open** > **Browse** in Power Apps Studio.

## Features

Description of the sample with possible additional details than in short summary.
This sample illustrates the following Power Fx concepts:

* If Statement with 2, and 3 conditions
* Value functions
* Text function
* Using "" for string/text wrapping



## Functions


### [Color]

Get colors for the fill Property, without using RGBA codes.

### [If]

If it matches your condition, followup with true or false actions/further functions.

### [Text]

Recognise the parameter as text (to use for choice columns, or converting other formats to text)

### [Value]

Recognise the parameter as values (to use for currency, numbers, or converting other formats to values)

#### Syntax


```excel
If(Value('KPI Value 1 Text 1'.Text)<20,Color.Green,Color.Red)
```


Parameter | Description | Required | Type
---|---|---|--
KPI Value 1 Text 1 |Text label holding the number/value| Yes |Value

#### Output

If the value is less than 20, make green, otherwise make red.

#### Syntax


```excel
If(Value('KPI Value Text 2'.Text)<20,Color.Green,If(Value('KPI Value Text 2'.Text) >=20 And Value('KPI Value Text 2'.Text) <=40, Color.Orange,Color.Red))
```

Parameter | Description | Required | Type
---|---|---|--
KPI Value Text 2'.Text |Text label holding the value| Yes | Value


#### Output

If the value is below 20, make green. Between 20 and 39, make orange. 40 equal and larger make red.


#### Syntax


```excel
If(Text('KPI Text.Text) =Resolved within same day,Color.Green,Color.Red)
```


Parameter | Description | Required | Type
---|---|---|--
KPI Text.Text |Text label holding the text| Yes | Text



#### Output

This function enables colors based on whether it's Resolved within same day. It's hardcoded to this text, but you can use variables.


## Disclaimer

**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

## Help

> Note: don't worry about this section, we'll update the links.

We do not support samples, but we this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.

If you encounter any issues while using this sample, [create a new issue](https://github.com/pnp/powerfx-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=YOUR-SOLUTION-NAME&authors=@YOURGITHUBUSERNAME&title=YOUR-SOLUTION-NAME%20-%20).

For questions regarding this sample, [create a new question](https://github.com/pnp/powerfx-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=YOUR-SOLUTION-NAME&authors=@YOURGITHUBUSERNAME&title=YOUR-SOLUTION-NAME%20-%20).

Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/powerfx-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=YOUR-SOLUTION-NAME&authors=@YOURGITHUBUSERNAME&title=YOUR-SOLUTION-NAME%20-%20).

<img src="https://telemetry.sharepointpnp.com/powerfx-samples/samples/readme-template" />
Binary file not shown.
8 changes: 8 additions & 0 deletions samples/ifcolorconditions-function/sourcecode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# msbuild output directories
/bin
/obj

# MSBuild Binary and Structured Log
*.binlog
49 changes: 49 additions & 0 deletions samples/ifcolorconditions-function/sourcecode/KPI.cdsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PowerAppsTargetsPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\PowerApps</PowerAppsTargetsPath>
</PropertyGroup>

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.props" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.props')" />

<PropertyGroup>
<ProjectGuid>a0003252-9093-423c-be24-46bd229e11c7</ProjectGuid>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<!--Remove TargetFramework when this is available in 16.1-->
<TargetFramework>net462</TargetFramework>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<SolutionRootPath>src</SolutionRootPath>
</PropertyGroup>

<!-- Solution Packager overrides, un-comment to use: SolutionPackagerType (Managed, Unmanaged, Both)
<PropertyGroup>
<SolutionPackageType>Managed</SolutionPackageType>
</PropertyGroup>
-->

<ItemGroup>
<PackageReference Include="Microsoft.PowerApps.MSBuild.Solution" Version="1.*" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\.gitignore" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\bin\**" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\obj\**" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.cdsproj" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.cdsproj.user" />
<ExcludeDirectories Include="$(MSBuildThisFileDirectory)\*.sln" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\**" Exclude="@(ExcludeDirectories)" />
<Content Include="$(SolutionPackageZipFilePath)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<Import Project="$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.targets" Condition="Exists('$(PowerAppsTargetsPath)\Microsoft.PowerApps.VisualStudio.Solution.targets')" />

</Project>
1 change: 1 addition & 0 deletions samples/ifcolorconditions-function/sourcecode/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<CanvasApp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>crc69_kpiusecases_d7e01</Name>
<AppVersion>2023-03-29T15:16:18Z</AppVersion>
<Status>Ready</Status>
<CreatedByClientVersion>3.23032.12.0</CreatedByClientVersion>
<MinClientVersion>3.23032.12.0</MinClientVersion>
<Tags>{"primaryDeviceWidth":"1366","primaryDeviceHeight":"768","supportsPortrait":"true","supportsLandscape":"true","primaryFormFactor":"Tablet","publisherVersion":"3.23032.12","minimumRequiredApiVersion":"2.2.0","hasComponent":"false","hasUnlockedComponent":"false","isUnifiedRootApp":"false","sienaVersion":"20230329T151618Z-3.23032.12.0"}</Tags>
<IsCdsUpgraded>0</IsCdsUpgraded>
<GalleryItemId xsi:nil="true"></GalleryItemId>
<BackgroundColor>RGBA(0,176,240,1)</BackgroundColor>
<DisplayName>KPIUsecases</DisplayName>
<Description xsi:nil="true"></Description>
<CommitMessage xsi:nil="true"></CommitMessage>
<Publisher xsi:nil="true"></Publisher>
<AuthorizationReferences>[]</AuthorizationReferences>
<ConnectionReferences>{}</ConnectionReferences>
<DatabaseReferences>{}</DatabaseReferences>
<AppComponents>[]</AppComponents>
<AppComponentDependencies>[]</AppComponentDependencies>
<CanConsumeAppPass>1</CanConsumeAppPass>
<CanvasAppType>0</CanvasAppType>
<BypassConsent>0</BypassConsent>
<AdminControlBypassConsent>0</AdminControlBypassConsent>
<EmbeddedApp xsi:nil="true"></EmbeddedApp>
<IntroducedVersion>1.0</IntroducedVersion>
<CdsDependencies>{"cdsdependencies":[]}</CdsDependencies>
<IsCustomizable>1</IsCustomizable>
<BackgroundImageUri>/CanvasApps/crc69_kpiusecases_d7e01_BackgroundImageUri</BackgroundImageUri>
<DocumentUri>/CanvasApps/crc69_kpiusecases_d7e01_DocumentUri.msapp</DocumentUri>
</CanvasApp>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"FormatVersion": "0.24",
"Header": {
"DocVersion": "1.330",
"MinVersionToLoad": "1.327",
"MSAppStructureVersion": "2.0"
},
"Properties": {
"AppCreationSource": "AppFromScratch",
"AppDescription": "",
"AppPreviewFlagsMap": {
"aibuilderserviceenrollment": false,
"allowmultiplescreensincanvaspages": false,
"appinsightserrortracing": false,
"appinstrumentationcorrelationtracing": false,
"autocreateenvironmentvariables": false,
"backfromhostaction": false,
"behaviorpropertyui": false,
"blockmovingcontrol": true,
"cdsdataformatting": false,
"classiccontrols": false,
"consistentreturnschemafortabularfunctions": true,
"copyandmerge": false,
"datatablev2control": true,
"dataverseactionsenabled": false,
"delaycontrolrendering": true,
"delayloadscreens": true,
"disablecdsfileandlargeimage": false,
"dynamicschema": false,
"enableappembeddingux": false,
"enablechatbotfeature": false,
"enablecomponentnamemaps": false,
"enablecomponentscopeoldbehavior": false,
"enablecopilotcontrol": false,
"enableeditcacherefreshfrequency": false,
"enableexcelonlinebusinessv2connector": true,
"enableideaspanel": true,
"enablelegacybarcodescanner": false,
"enableonstart": true,
"enableonstartnavigate": false,
"enablepcfmoderndatasets": true,
"enablepowerautomatepane": true,
"enablerowscopeonetonexpand": false,
"enablerpawarecomponentdependency": true,
"enablerulespanel": false,
"enableruntimepolicies": false,
"enablesaveloadcleardataonweb": false,
"enhanceddelegation": true,
"enhancedgalleryinitialization": true,
"errorhandling": true,
"excelcompatibility": false,
"expandedsavedatasupport": true,
"exportimportcomponents2": true,
"externalmessage": false,
"fluentv9controls": true,
"formuladataprefetch": true,
"formularepair": true,
"generatedebugpublishedapp": false,
"herocontrols": false,
"improvedmediacapture": false,
"improvedtabstopbehavior": false,
"keeprecentscreensloaded": false,
"longlivingcache": false,
"namedformulas": false,
"nativecdsexperimental": true,
"optimizedforteamsmeeting": false,
"packagemodernruntime": false,
"parallelcodegen": false,
"pdffunction": false,
"projectionmapping": true,
"reactformulabar": false,
"reliableconcurrent": true,
"reverttooldpowerautomate": false,
"rtlinstudiopreview": false,
"rtlsupport": false,
"supportcolumnnamesasidentifiers": false,
"tabledoesntwraprecords": true,
"untypedobject": false,
"usedisplaynamemetadata": true,
"useenforcesavedatalimits": true,
"useexperimentalcdsconnector": true,
"useexperimentalsqlconnector": true,
"useguiddatatypes": true,
"usenonblockingonstartrule": true,
"webbarcodescanner": false,
"zeroalltabindexes": true
},
"Author": "",
"ContainsThirdPartyPcfControls": false,
"DefaultConnectedDataSourceMaxGetRowsCount": 500,
"DocumentAppType": "DesktopOrTablet",
"DocumentLayoutHeight": 768,
"DocumentLayoutLockOrientation": false,
"DocumentLayoutMaintainAspectRatio": true,
"DocumentLayoutOrientation": "landscape",
"DocumentLayoutScaleToFit": true,
"DocumentLayoutWidth": 1366,
"DocumentType": "App",
"EnableInstrumentation": false,
"FileID": "45320f72-d3f2-44ad-8af9-2771b8b0f7d7",
"Id": "45320f72-d3f2-44ad-8af9-2771b8b0f7d7",
"InstrumentationKey": "",
"LocalDatabaseReferences": "{}",
"Name": "KPIUsecases",
"OriginatingVersion": "1.330"
},
"PublishInfo": {
"AppName": "KPIUsecases",
"BackgroundColor": "RGBA(0,176,240,1)",
"IconColor": "RGBA(255,255,255,1)",
"IconName": "Edit",
"LogoFileName": "",
"PublishDataLocally": false,
"PublishResourcesLocally": false,
"PublishTarget": "player",
"UserLocale": "en-US"
},
"ScreenOrder": [
"Screen1"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading