top of page
Jihwan Kim

Standardizing Number Formats in Power BI Reports by Implementing a Dynamic Format String Table

In this writing, I like to share how I learned to use dynamic format string by implementing format_string table to Power BI semantic model.

Current Situation

My team is working on over 20 reports and semantic models, and recently the team realizes that In the current state of Power BI reporting, the formatting of numerical values is inconsistent across different reports and datasets.

Often, report authors manually define dynamic format strings for measures and visuals. This lack of standardization leads to potential confusion, decreased readability, and inefficiencies when managing multiple reports or updating format standards across datasets.

The manual approach also introduces the risk of human error, making it difficult to maintain uniformity, especially when reports are modified or extended by multiple users.


The Need for Standardization

As the demand for accurate, clean, and consistent reporting increases, there is a need for a unified solution that ensures standard number formatting across all Power BI reports and datasets.

Creating a standardized format string table will not only streamline the process of building reports but also ensure that numerical values are always represented in a consistent, professional manner.


Benefits of Implementing a Standardized Format String Table

Consistency Across Reports

By defining and applying a standardized format string, all reports will follow the same rules for displaying numerical values.

This will provide clarity for users across different reports and ensure the alignment in presentation.

Reduced Manual Effort

A central format string table eliminates the need to manually write format strings each time a new DAX measure is created. Developers can refer to the predefined table, which saves time and avoids duplication of effort.

Flexibility in Updates

When the standard needs to be updated (e.g., changing how thousands or decimals are represented), the changes can be made in the format string table, and all DAX measures in reports using this standard will automatically reflect the update without requiring individual changes to each report.

Improved Collaboration

All developers in the team can work on based on the same format-string-table with the assurance that the format standards are clearly defined. This promotes a shared understanding and reduces the chance of inconsistent formatting practices across reports.

Error Prevention

Standardizing the format reduces the potential for human error when manually defining formats, thus improving the accuracy of the final report.


Outcome of the Implementation

By implementing a standardized format string table, Power BI developers will experience improved efficiency and consistency.

This approach will lead to faster report creation and maintenance, while also providing a uniform user experience for stakeholders consuming the reports.

Over time, it will foster better collaboration and a cleaner, more professional presentation of data across the organization.


How It Works: Format String Table Implementation

To implement a dynamic format string table in Power BI, follow these steps:


1. Create a Format String Table: Define a new table (the table down below) in Power BI (or import the below table into Power BI) that stores the desired format strings for different number scale.


index

min

max

format_string

1

-1.00E+20

-1.00E+14

"#,#0,,,,.T"

2

-1.00E+14

-1.00E+13

"#0,,,,.0T"

3

-1.00E+13

-1.00E+12

"#0,,,,.00T"

4

-1.00E+12

-1.00E+11

"#,#0,,,.B"

5

-1.00E+11

-1.00E+10

"#0,,,.0B"

6

-1.00E+10

-1.00E+09

"#0,,,.00B"

7

-1.00E+09

-1.00E+08

"#,#0,,.M"

8

-1.00E+08

-1.00E+07

"#0,,.0M"

9

-1.00E+07

-1.00E+06

"#0,,.00M"

10

-1.00E+06

-1.00E+05

"#,#0,.K"

11

-1.00E+05

-1.00E+04

"#0,.0K"

12

-1.00E+04

-1000

"#0,.00K"

13

-1000

-100

"#,#0"

14

-100

-10

"#0.0"

15

-10

-1

"#0.00"

16

-1

-0.1

"0.00"

17

-0.1

-0.01

"0.000"

18

-0.01

-0.001

"0.0000"

19

-0.001

0

"0.00000"

20

0

0.001

"0.00000"

21

0.001

0.01

"0.0000"

22

0.01

0.1

"0.000"

23

0.1

1

"0.00"

24

1

10

"#0.00"

25

10

100

"#0.0"

26

100

1000

"#0"

27

1.00E+03

1.00E+04

"#0,.00K"

28

1.00E+04

1.00E+05

"#0,.0K"

29

1.00E+05

1.00E+06

"#,#0,.K"

30

1.00E+06

1.00E+07

"#0,,.00M"

31

1.00E+07

1.00E+08

"#0,,.0M"

32

1.00E+08

1.00E+09

"#,#0,,.M"

33

1.00E+09

1.00E+10

"#0,,,.00B"

34

1.00E+10

1.00E+11

"#0,,,.0B"

35

1.00E+11

1.00E+12

"#,#0,,,.B"

36

1.00E+12

1.00E+13

"#0,,,,.00T"

37

1.00E+13

1.00E+14

"#0,,,,.0T"

38

1.00E+14

1.00E+20

"#,#0,,,,.T"


2. Link the Format String Table to Measures by writing DAX formula: In the report, refer to this table when defining the dynamic format for your measures. Use DAX to apply the appropriate format string based on the scenario.


3. Apply the Format to the DAX measure: Once the format string is linked to a measure, the number format will automatically adjust based on the type of data being displayed in the visuals.


VAR _measure =
    SELECTEDMEASURE ()
VAR _result =
    MAXX (
        FILTER (
            'format_string',
            _measure >= 'format_string'[min]
                && _measure < 'format_string'[max]
        ),
        'format_string'[format_string]
    )
RETURN
    _result


Conclusion and Suggestion

Implementing a standardized format string table in Power BI ensures that reports maintain a consistent, professional appearance across datasets.

This approach streamlines report creation, reduces manual effort, and enhances the scalability of report management.

Standardization improves data presentation and fosters a more efficient reporting process, benefiting both Power BI developers and end users alike.


Additionally, if there is a way to integrate the format string table into the source and all Power BI semantic model import format_string table from the source, Power BI developers could establish a single source of truth for formatting rules. This would allow the same formatting logic to be applied consistently across all reports, further enhancing efficiency and standardization.


I hope this helps Power BI developers having fun in playing with dynamic format string.

24 views0 comments

Comments


bottom of page