Forum Discussion
Matrix table
- 6 months ago
Thankyou, rohit1991, cengizhanarslan, FBergamaschi, krishnakanth240, and techies for your responses.
Hi Easley06,Thankyou for the update.
As suggested by FBergamaschi, krishnakanth240, and techies, please provide sample data that clearly demonstrates your issue or query in a structured format (not as an image) to help us understand and resolve the matter. Ensure that the data is relevant, free from any sensitive information, and directly related to the issue. Additionally, please share the expected outcome based on the given example.
Thank you.
1) Create a disconnected “Column Layout” table
You can do this in DAX (or Power Query). This version is easiest to understand:
A) Disconnected table for Metrics
Metrics =
DATATABLE (
"Metric", STRING,
{
{ "OTD" },
{ "NET SALES" },
{ "COST of sales" },
{ "gross" }
}
)B) Disconnected table for Months
Months =
DISTINCT (
SELECTCOLUMNS (
'Date',
"MonthStart", DATE ( YEAR('Date'[Date]), MONTH('Date'[Date]), 1 ),
"MonthLabel", FORMAT ( 'Date'[Date], "MMM-yy" )
)
)
C) Crossjoin to create the final matrix columns table
MatrixColumns =
CROSSJOIN (
SELECTCOLUMNS ( Months, "MonthStart", [MonthStart], "MonthLabel", [MonthLabel] ),
SELECTCOLUMNS ( Metrics, "Metric", Metrics[Metric] )
)No relationships from MatrixColumns to your model.
2) Put fields into the Matrix
Rows: Region, Store, Product
Columns: MatrixColumns[MonthLabel] then MatrixColumns[Metric]
Values: the single measure below
3) Create one “dynamic value” measure (TREATAS + SWITCH)
Matrix Value =
VAR _MonthStart = SELECTEDVALUE ( MatrixColumns[MonthStart] )
VAR _Metric = SELECTEDVALUE ( MatrixColumns[Metric] )
RETURN
SWITCH (
TRUE(),
_Metric = "OTD",
CALCULATE ( [OTD], TREATAS ( { _MonthStart }, 'Date'[MonthStart] ) ),
_Metric = "NET SALES",
CALCULATE ( [Net Sales], TREATAS ( { _MonthStart }, 'Date'[MonthStart] ) ),
_Metric = "COST of sales",
CALCULATE ( [Cost of Sales], TREATAS ( { _MonthStart }, 'Date'[MonthStart] ) ),
_Metric = "gross",
CALCULATE ( [Gross], TREATAS ( { _MonthStart }, 'Date'[MonthStart] ) )
)This forces the correct month filter without needing the month to come from your real Date table (because the month is coming from the disconnected table).
Hi,
for the result im getting only blank values..