问题
I need to create a custom header like the picture below:
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?
Edit
Dim_prduit
My problem is how to dispaly Nombre product , and then like hierarchy dim5 then dim6 in the header?
回答1:
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:
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.
回答2:
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:
- Build your own custom visualization, using Javascript, Python or R
- Use a pixel-perfect tool like SSRS
来源:https://stackoverflow.com/questions/61408239/custom-matrix-header