1

I need to create a custom header like the picture below:

enter image description here

I check this link Custom aggregate column in power bi matrix But I don't undestand how to do the same to my case?

Edit

I try to create calculated table but I didn't get the data for dim5 and dim6, how can I modify it?

enter image description here

Edit

Dim_prduit

enter image description here

My problem is how to dispaly Nombre product , and then like hierarchy dim5 then dim6 in the header?

2 Answers2

0

Power BI is not a pixel-perfect data visualization tool, therefore, it is not possible to create customer headers using Built-in visualizations.

Therefore you have pretty much two options:

  1. Build your own custom visualization, using Javascript, Python or R
  2. Use a pixel-perfect tool like SSRS
Seymour
  • 3,104
  • 2
  • 22
  • 46
0

It's ugly but you can write a header table like this and then define a switching measure based on the appropriate indices:

Header = 
ADDCOLUMNS (
    UNION (
        DATATABLE (
            "Top", STRING,
            "Index1", INTEGER,
            "Middle", STRING,
            "Index2", INTEGER,
            "Bottom", STRING,
            "Index3", INTEGER,
            {
                { "Nombre product", 1, "", 0, "", 0 },
                { "Affaires nouvelles", 2, "Total", 8, "", 0 },
                { "Affaires nouvelles", 2, "%Total", 9, "", 0 }
            }
        ),
        SELECTCOLUMNS (
            SUMMARIZECOLUMNS ( Dim_Prod[dim5], Dim_Prod[dim6] ),
            "Top", "Affaires nouvelles",
            "Index1", 2,
            "Middle", Dim_Prod[dim5],
            "Index2", RANK.EQ ( Dim_Prod[dim5], Dim_Prod[dim5], ASC ),
            "Bottom", Dim_Prod[dim6],
            "Index3", RANK.EQ ( Dim_Prod[dim6], Dim_Prod[dim6] )
        )
    ),
    "Index0", 100 * [Index1] + 10 * [Index2] + [Index3]
)

Output:

Output


Sample measure:

SampleMeasure =
VAR Top = SELECTEDVALUE ( Header[Top] )
VAR Middle = SELECTEDVALUE ( Header[Middle] )
VAR BottomIndex = SELECTEDVALUE ( Header[Index3] )
RETURN
    SWITCH (
        TRUE (),
        Top = "Nombre product", [NombreProductMeasure],
        Top = "Affaires nouvelles" && BottomIndex <> 0, [DimensionMeasure],
        Middle = "Total", [TotalMeasure],
        Middle = "%Total", [%TotalMeasure]
    )

This is pretty hacky though. Power BI may not be the best tool here.

Alexis Olson
  • 38,724
  • 7
  • 42
  • 64
  • A `SWITCH` to define what calculation to use in what situation. – Alexis Olson Apr 27 '20 at 23:35
  • In the matrix, I will put in the column part, top then middle then bottom? –  Apr 27 '20 at 23:40
  • Yep. 3 levels in that order. You'll have to drill down to expand the columns. – Alexis Olson Apr 27 '20 at 23:41
  • For the measure calculation, can you put an example? I'm not sure that I understand it's quiet difficult. –  Apr 28 '20 at 00:15
  • 1
    I've added an example. – Alexis Olson Apr 28 '20 at 02:02
  • Could you please help me to figure out how to use DimensionMeasure correctly? I put an example in the following question https://stackoverflow.com/questions/61543224/wrong-values-with-customized-double-header-in-matrix . If you have any idea that you can help me. Thank you. –  May 07 '20 at 14:17