简体   繁体   中英

How to add a measure at the end of the matrix, which performs certain calculations in Power BI?

The output matrix in Power BI should contain the measures X, Y, and Z. Where

  1. X = (B+C);
    X = IF((MAX(Sheet1[C1])) = "B", SUM(Sheet1[C2]), IF(MAX(Sheet1[C1]) = "C", SUM(Sheet1[C2])))

  2. Y = A - (B+c);
    Y = IF(MAX(Sheet1[C1]) = "A", CALCULATE( ((-1) * SUM(Sheet1[C2])) + [X]))

  3. Z = (A/(A-(B+c)))*100%

I have achieved till total which is quite easy but, I am unable to replicate the same output in Power BI.

Thanks.

示例图片

I have tried and found a way to achieve the above result with a couple of slicers and more tables, sadly I have only succeeded to achieve till Y = A-(B+C) .

SO the whole visualisation till Y will be a combination of tables and matrices. To achieve the desired visual, I followed the following steps:

  1. Start by creating a matrix with columns C1 and C2 in the row section of the matrix and the C2 in the Value section of the matrix and set it to the sum of 'C2`.

矩阵输出

  1. Create a measure X with the following formula:

     X = IF(((MAX(Sheet1[C1])) = "B" || (MAX(Sheet1[C1]) = "C")), SUM(Sheet1[C2]))

Create a table with the column C1 and measure X in it.

  1. Create a slicer with C1 , open the Format pane go to Edit Interaction options, and set the interaction to only the Table having measure X and the column C1 , disable any other interaction.

  2. In the slicer select the option B and C , because the X is only concerned with the values B & C. The table should display the total.

表十

  1. Create another measure Y with the following DAX:

     Y = CALCULATE(SUM(Sheet1[C2]), KEEPFILTERS(Sheet1[C1] = "A")) + CALCULATE(-SUM(Sheet1[C2]), KEEPFILTERS(Sheet1[C1] IN {"B", "C"}))
  2. Repeat the steps 3 & 4 again for measure Y. This should be your output.

Y输出

  1. Now hide all the extra slicers from the Selection option in the Format pane in the ribbon and properly format all the tables and set the layer order as follows:

切片机

  1. This should be the final output.

最终输出

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM