cancel
Showing results for 
Search instead for 
Did you mean: 

The workaround of using the measure as axis in the visual

Scenario

For Power BI users, a problem often encountered is that they want to put the measure on the axis, but find that it cannot be achieved. Especially beginners want to do this habitually. Below I will give an example to explain this problem.

 

Basic situation: After a period of merchandise sales, a group of sales representatives will face performance evaluation.

 

Table used: 

V-lianl-msft_0-1613033295359.png

 

There are 11 people in the table, and sales range from 130 to 200. According to dynamic assessment standards, real-time statistics are made on the number of people who have passed and failed the assessment standards.

 

Common incorrect solutions for the beginners (By creating a calculated column/measure): 

 

Create a calculated column named [Result].

V-lianl-msft_1-1613033311465.png

 

The passing standard is 160, 6 people passed the assessment standard, and 5 failed.

 

Create a measure [Count people] to count the number of people in different states.

 

 Count people = COUNTROWS(‘Table’)

 

 

Create a stacked column chart. Take [Result] as the axis and [Count people] as the value. You can see the statistics of the number of people classified as ‘Passed the assessment’ and ‘Failed the assessment’.

V-lianl-msft_2-1613033326622.png

 

Create a what-if parameter to a dynamic assessment standards.

V-lianl-msft_3-1613033355349.png

 

After the above operations, the [Assessment standard] parameter table and slider control will be automatically generated.

Modify the [Result] calculated column as

V-lianl-msft_4-1613033366730.png

 

 

Then, in theory you can use a slicer containing [Assessment standard] to dynamically filter the results. However, after practice, since the calculated column will not be affected by slicers or filters, and the default value of [Assessment standard Value] is 160, [Result] will not dynamically get a new value.

The principle of the calculated column is: it is calculated once when the data is loaded, and it mainlyccupies memory resources; the measure is calculated in real time as the calculation context changes, and it mainly occupies CPU resources.

V-lianl-msft_5-1613033383616.png

 

 

  1. If the calculated column fails, then let's try to create a measure. Create a measure asV-lianl-msft_6-1613033412150.png
  2. Create a stacked column chart. Then you will find that the [Assessment standard Measure] can’t be put into the axis.

V-lianl-msft_7-1613033423202.png

 

Correct solution:

  1. Create a new table named [Type].

    V-lianl-msft_8-1613033437282.png

  2. Create a measure.

    V-lianl-msft_9-1613033461601.png

  3. Put the [Dynamic Measure] measure and the [Type] column into the stacked column chart. The values will dynamically change the results according to the filter of the slicer.

V-lianl-msft_11-1613033517978.png

 

Since the chart must present the meaning of the logical relationship between the data, the data must be grouped according to certain standards (dimensions), and then various aggregation operations are performed. This is the fundamental reason why the measurement value cannot be used as the axis of the chart.

 

Summary:

  1. When there is a lot of detailed data, in order to ensure the efficiency of report opening, try to use measures instead of calculated columns; if you need to adjust parameters in real time and obtain analysis results in real time, you can only use measures.
  2. For more details about DAX, you can refer to: DAX in tabular models.
  3. (1) Create a transition table corresponding to each possible classification type;

 

(2) Use the classification standard field of the transition table as the axis field in the chart (grouping condition);

 

(3) Construct a separate type for each category ([Compliant] and [Not Compliant]);

 

(4) Construct the [quantity selection] measure, and call the corresponding individual count metric value as the value field of the chart by judging the classification criteria of the filtering context.

 

Please check the attached file for details. 

 

 

 

Author: Stephen Tao

Reviewer: Kerry & Ula