Skip to main content

Display dynamic units (in K, in M) in Power BI

Step 1: Load data to Power BI Desktop

Open Power BI desktop

 Click on use sample data to load sample data to Power BI desktop

Click on load sample data to load data to model.

Sample data looks like below

Step 2 : Create measure table

Home à click on enter data under data section

Create table as Measure

Click on load


Have created below 4 measures

Profit = SUM(financials[Profit])

Sales = SUM(financials[Sales])

Units Sold = SUM(financials[Units Sold])

Gross Sales = SUM(financials[Gross Sales])

Step 3: Create new table for display format

Go to modeling tab

Click on new table under calculations section and provide below query to new table

DisplayFormat =

DATATABLE(

    "FormatOptions",STRING,

    "Sort",INTEGER,

    {

        {"Millions",1},

        {"Thousands",2},

        {"Original Values",3}

    }

)

Click on save


Step 4: Create dynamic measures

Click on three dots (…) in measure table and create new dynamic measures

Dynamic Sales:

Dynamic Sales =

VAR FormatOption =

    SELECTEDVALUE('DisplayFormat'[FormatOptions])

VAR BaseValue = [Sales]

VAR Multiplier = SWITCH(FormatOption,

    "Millions",1000000,

    "Thousands",1000,

    "Original Values",1)

VAR AdjustedValue = BaseValue / Multiplier

RETURN AdjustedValue

Dynamic Profit:

Dynamic Profit =

VAR FormatOption =

    SELECTEDVALUE('DisplayFormat'[FormatOptions])

VAR BaseValue = [Profit]

VAR Multiplier = SWITCH(FormatOption,

    "Millions",1000000,

    "Thousands",1000,

    "Original Values",1)

VAR AdjustedValue = BaseValue / Multiplier

RETURN AdjustedValue

Dynamic GrossSales:

Dynamic GrossSales =

VAR FormatOption =

    SELECTEDVALUE('DisplayFormat'[FormatOptions])

VAR BaseValue = [Gross Sales]

VAR Multiplier = SWITCH(FormatOption,

    "Millions",1000000,

    "Thousands",1000,

    "Original Values",1)

VAR AdjustedValue = BaseValue / Multiplier

RETURN AdjustedValue

Dynamic UnitsSold:

Dynamic UnitsSold =

VAR FormatOption =

    SELECTEDVALUE('DisplayFormat'[FormatOptions])

VAR BaseValue = [Units Sold]

VAR Multiplier = SWITCH(FormatOption,

    "Millions",1000000,

    "Thousands",1000,

    "Original Values",1)

VAR AdjustedValue = BaseValue / Multiplier

RETURN AdjustedValue

 

Step 5: Bring slicer to canvas page


Drag DisplayFormat column to slice

Step 6: Create visualization

Drag and drop table to canvas page

Select required columns to table visual

Default it will show Infinity for measure values

Select values in Millions in slicer pane


Comments

Popular posts from this blog

SSRS INTERVIEW QUESTIONS

Q: What is SSRS? Ø   SSRS or SQL Server Reporting Service is a server-based report generation software systems from Microsoft and is part of Microsoft BI. Ø   It is used for preparing and delivering interactive and variety of reports. Ø   It is administered through an web based interface. Ø   Reporting services utilizes a web service interface for supporting and developing of customized reporting applications. Ø   SSRS lets you create very rich reports (Tabular/Graphical/Interactive) from various datasources with rich data visualization (Charts, Maps, sparklines) Ø   SSRS allows are reports to be exported in various formats (Excel, PDF, word etc) Q: Explain SSRS Architecture? Reporting services architecture comprises of integrated components. It is a multi-tiered, included with application, server and data layers. This architecture is scalable and modular. A single installation can be used across multiple computers. It includes the fo...

Exception deserializing the package "The process cannot access the file because it is being used by another process."

TITLE: Microsoft Visual Studio ------------------------------ Failed to start project ------------------------------ ADDITIONAL INFORMATION: Exception deserializing the package "The process cannot access the file 'E:\SSASCube\HistoricalDataLoad\HistoricalDataLoad\bin\Development\HistoricalDataLoad.ispac' because it is being used by another process.". (Microsoft.DataTransformationServices.VsIntegration) ------------------------------ The process cannot access the file 'E:\SSASCube\HistoricalDataLoad\HistoricalDataLoad\bin\Development\HistoricalDataLoad.ispac' because it is being used by another process. (mscorlib) ------------------------------ BUTTONS: OK ------------------------------ While running SSIS package i got the error “The process cannot access the file ‘*.ispac’ because it is being used by another process”. I tried to close SSDT and run it again but, I still got the same error while compiling. Then, after searching over internet, I got...

Failed to execute the package or element. Build errors were encountered

Error: TITLE: Microsoft Visual Studio ------------------------------ Failed to execute the package or element.   Build errors were encountered. For more information, see the Output window. ------------------------------ BUTTONS: OK ------------------------------   Solution: We tried to close SSDT and run it again but, we still got the same error while running SSIS package. Then, we need to follow bellow solution: Step 1: Go to Task Manager–> Details Tab. Step 2: Locate the process “ DtsDebugHost.exe “. Kill this process. There might be multiple instances of this process. Kill all of them. Step 3: Rerun SSIS package