Forum Discussion
Matrix with dynamic rows?
You may try the following solution. It is not an optimum solution, but a simple one to start with.
Step 1:
Add a calendar table to your data model. Select "New Table" and use the following DAX code.
Calendar = CALENDAR(DATE(2020,1,1),DATE(2020,2,29))
Change the date ranges as per your requirement.
Step 2:
Add another calculated table to your data model. Select "New Table" and use the following DAX code.
VehicleCalendar = CROSSJOIN(Vehicles,'Calendar')
Step 3:
Add two calculated columns to the "VehicleCalendar" table that you have added in Step 2.
Appointed Department =
CONCATENATEX (
FILTER (
'Appointed Department',
AND (
AND (
'Appointed Department'[From] <= VehicleCalendar[Date],
'Appointed Department'[TillDate] >= VehicleCalendar[Date]
),
'Appointed Department'[Vehicle] = VehicleCalendar[Vehicle]
)
),
'Appointed Department'[Appointed Department]
)Relevant Department =
IF (
ISBLANK ( VehicleCalendar[Appointed Department] ),
VehicleCalendar[Standard Department],
VehicleCalendar[Appointed Department]
)
Step 3a: Add another calculated column to the "Appointed Department" table.
TillDate = IF(ISBLANK('Appointed Department'[Till]),MAX('Calendar'[Date]),'Appointed Department'[Till])Step 4: Add a measure
Turnover = SUMX(Turnover,Turnover[Turnover])
The relationships should be as follows...
Please pay attention to the Cardinality and Cross Filter Directions of the relationships
Step 5:
Add a date slicer to your data model using the "Date" field from the "Calendar" table.
Step 6:
Add a matrix visual and add the "Relevant Department" and "Vehicle" Columns from the table named "Vehicle Calendar" into the Rows of the matrix visual.
Step 7:
Add the measure named "Turnover " that we have created in Step 4 to the "Values" section of the matrix visual.
This will give the results as shown in my earlier post.
This may not be the most optimum solution, but once you do this, you will get started and you can further improvise.
Thanks a lot for this help, really appreciated!!!
The one thing left is that we only have to look at the "Till" ("Tot") date to determine the "Department Appointed".
So for the below scenario, since 14/02/2020 is in the latest period, only IBERICA should be visible. Is this something we can achieve as well?
- Anonymous6 years agoNot applicable
If you only need to select the till date only, then you can just change the date selector to "Drop Down" instead of "Between" as shown in the images below. Then set the "Single Select" property of the date slicer to true.
- BramSegers6 years agoFrequent Visitor
First of all, thanks again for the reply.
That would indeed work, but as I said it's a simplified dataset. The actual dataset has a calculated turnover for the selected period as well and should appear on the department the vehicle belongs to on the end of the selected period.
- Anonymous6 years agoNot applicable
I am not able to understand your problem. Whatever solution I have posted is based on the table structures and sample data you have posted here. It is okay that you post a few dummy data, and the volume of your actual data is huge. But all the table structures and the relationships, basically your data model, should be the same as what you have posted here. Only then the solution will work.