SELECTEDMEASUREFORMATSTRING

How to Use the Power BI DAX function SELECTEDMEASUREFORMATSTRING

Understanding the SELECTEDMEASUREFORMATSTRING Function

The SELECTEDMEASUREFORMATSTRING function is used to format the values of a measure based on the current selection in a report. This function takes two arguments: the first argument is the format string, and the second argument is the measure name. The format string is used to define the format of the measure value. The measure name is used to specify the measure to which the format should be applied.

Here is the syntax for the SELECTEDMEASUREFORMATSTRING function:


SELECTEDMEASUREFORMATSTRING (format_string, measure_name)


Using the SELECTEDMEASUREFORMATSTRING Function in Power BI

To use the SELECTEDMEASUREFORMATSTRING function in Power BI, follow the steps below:

1. Open Power BI Desktop and create a new report.

2. Add a table or chart to the report.

3. Add a measure to the table or chart.

4. Select the measure and go to the Format pane.

5. In the Format pane, expand the Data label section.

6. Click the fx button next to the Label field.

7. In the formula bar, type the SELECTEDMEASUREFORMATSTRING function with the appropriate arguments.

8. Press Enter to apply the function to the measure.

Here is an example of how to use the SELECTEDMEASUREFORMATSTRING function:

Suppose you have a measure named "Total Sales" that calculates the total sales for a particular product. You want to format the measure dynamically based on the current selection in the report. You can use the SELECTEDMEASUREFORMATSTRING function to achieve this.


SELECTEDMEASUREFORMATSTRING(“#,0.00”, “Total Sales”)


In this example, the format string "#,0.00" is used to format the measure value with two decimal places and a comma separator for thousands. The measure name "Total Sales" is specified as the second argument.

Tips for Using the SELECTEDMEASUREFORMATSTRING Function

Here are some tips for using the SELECTEDMEASUREFORMATSTRING function in Power BI:

- Use the format string to define the format of the measure value. The format string can include various symbols and placeholders to format the value.

- Use the measure name to specify the measure to which the format should be applied. Make sure that the measure name is spelled correctly.

- Test the function with different selections in the report to ensure that the format is applied correctly.

- Use the Format pane to adjust the font, color, and other visual properties of the measure label.

The SELECTEDMEASUREFORMATSTRING function is a powerful tool for formatting the values of a measure dynamically based on the current selection in a report. With this function, Power BI users can create more interactive and informative reports and dashboards. By following the steps and tips outlined in this article, you can use the SELECTEDMEASUREFORMATSTRING function in your own Power BI projects.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)