diff --git a/powerbi-docs/transform-model/desktop-visual-calculations-overview.md b/powerbi-docs/transform-model/desktop-visual-calculations-overview.md index e6a4e674ab..ee2a64ddce 100644 --- a/powerbi-docs/transform-model/desktop-visual-calculations-overview.md +++ b/powerbi-docs/transform-model/desktop-visual-calculations-overview.md @@ -266,6 +266,47 @@ Visual calculations also introduce a set of functions specific to visual calcula You can format a visual calculation using data types and formatting options. You can also set a [custom visual level format string](../create-reports/desktop-custom-format-strings.md). Use the **Data format** options in the General section of the formatting pane for your visual to set the format: :::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-format-strings.png" alt-text="Screenshot of the visual calculations edit mode showing a visual calculation that returns a percentage formatted as a percentage."::: +## Example 1: Using visual calculation to return a Hex color code for conditional formatting + +Step 1: Select The visual you would like to use the conditional formatting in: + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-01.png" alt-text="Screenshot of a table visual with two columns Value and Progress."::: + +Step 2: Click the **New visual calculation** button under the **Home** Tab: + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-02.png" alt-text="Screenshot of the button to create a visual calculation in the Power BI Home Tab."::: + +Step 3: Write your visual calculation. Here is a IF statement to return either green or red based on a measure being more then .5: + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-03.png" alt-text="Screenshot of DAX code listed out below in the visual calculation editor."::: + +```dax +Conditional Hex Code = IF ( [Progress] > .5, "#5BA300", "#E91C1C" ) +``` + +Step 4: Expand the Formatting pane and click **Properties**: + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-04.png" alt-text="Screenshot of the formatting pane showing that you should click properties."::: + +Step 5: Expand the **Data Format** section, select your visual calculation, and set both the Data Type and format to **Text**: + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-05.png" alt-text="Screenshot of the formatting pane showing you should apply a data type to your visual calculation of text."::: + +Step 6: Before exiting the visual calculation editor click the hide icon next to the visual calculation in the build section to hide it: + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-06.png" alt-text="Screenshot of the build pane showing how to click a button to hide the visual calculation you are creating."::: + +Step 7: Use it in a conditional formatting section: + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-07.png" alt-text="Screenshot of a conditional formatting window where the visual calculation has been selected."::: + +Step 8: Exit the visual calculation editor by clicking the **Back to report** button: + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-08.png" alt-text="Screenshot of the button you push to exit out of the visual calculation editor. Text is: Back to report."::: + +Step 9: Enjoy your conditional formatted visual! + +:::image type="content" source="media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-09.png" alt-text="Screenshot of the table from the first screenshot now with conditional formatting applied."::: ## Considerations and limitations diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-01.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-01.png new file mode 100644 index 0000000000..79c65a91da Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-01.png differ diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-02.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-02.png new file mode 100644 index 0000000000..02ba5ac8c6 Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-02.png differ diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-03.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-03.png new file mode 100644 index 0000000000..6ec59148fe Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-03.png differ diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-04.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-04.png new file mode 100644 index 0000000000..c669b91394 Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-04.png differ diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-05.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-05.png new file mode 100644 index 0000000000..eb4b000d32 Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-05.png differ diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-06.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-06.png new file mode 100644 index 0000000000..1a90c477ed Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-06.png differ diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-07.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-07.png new file mode 100644 index 0000000000..c48a9dc9ff Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-07.png differ diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-08.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-08.png new file mode 100644 index 0000000000..f5ecba54e5 Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-08.png differ diff --git a/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-09.png b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-09.png new file mode 100644 index 0000000000..443f98a426 Binary files /dev/null and b/powerbi-docs/transform-model/media/desktop-visual-calculations-overview/desktop-visual-calculations-hex-example-09.png differ