Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
hello all,
i am looking for a matrix like:
If i choose for example the first 9 month and the year 2020 i want to see (beside choosen year and 9 month) the last two years with the last choosen month. in two matrices it is no problem. but it is possible to show that in one matrix? in the rows i have hierchies with +/-. would be easier to control that in one matrix.
thanks for ideas.
Solved! Go to Solution.
Hi, @Pikachu-Power
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
YM(a calculated table):
YM = DISTINCT('Table'[YearMonth])
There is no relationship betweent two table. You may create a measure as below.
Result =
var x = MAX('YM'[YearMonth])
var y = VALUE(LEFT(x,4))
var m = VALUE(RIGHT(x,2))
return
IF(
MAX('Table'[YearMonth])<=x,
IF(
MAX('Table'[Year])=y,
IF(
MAX('Table'[Month])<=m,
1,0
),
IF(
MAX('Table'[Month])=m,
1,0
)
),
0
)
Then you need to put the measure in the visual level filter and use 'YearMonth' column from 'YM' table to filter the result.
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Pikachu-Power
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
YM(a calculated table):
YM = DISTINCT('Table'[YearMonth])
There is no relationship betweent two table. You may create a measure as below.
Result =
var x = MAX('YM'[YearMonth])
var y = VALUE(LEFT(x,4))
var m = VALUE(RIGHT(x,2))
return
IF(
MAX('Table'[YearMonth])<=x,
IF(
MAX('Table'[Year])=y,
IF(
MAX('Table'[Month])<=m,
1,0
),
IF(
MAX('Table'[Month])=m,
1,0
)
),
0
)
Then you need to put the measure in the visual level filter and use 'YearMonth' column from 'YM' table to filter the result.
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you noticed I added a MonthNum column. You can sort the Month column by that.
You can use the same approach to sort the years differently.
Let's assume we have a table with sample data
Table = ADDCOLUMNS(CALENDAR("2018-01-01","2021-12-31"),"Value",RANDBETWEEN(0,10),"MonthNum",MONTH([Date]),"Month",format([Date],"MMM"),"Year",YEAR([Date]))
Next step is to create disconnected tables that feed the Month and Year slicer
MSlicer = SUMMARIZE('Table','Table'[Month],'Table'[MonthNum])
YSlicer = VALUES('Table'[Year])
These slicers need to be made Single select.
next, add a measure.
Include := switch(true(),min('Table'[Year])=SELECTEDVALUE(YSlicer[Year]) && min('Table'[MonthNum])<SELECTEDVALUE(MSlicer[MonthNum]),1,
min('Table'[MonthNum])=SELECTEDVALUE(MSlicer[MonthNum]),1,0)
Then create your matrix visual, and add the measure to the visual filters, setting the filter to Include = 1
The result is as you expect. However you have a problem with the sorting of the years - I leave it up to you to decide how to do that.
Interesting solution, thanks. But the sorting will be really a problem. Is it possible to sort like in my picure? I also cant sort the month for the current year like in your case... the matrix only sorts for values.
And something like 2020 01, 2020 02 would make the table too wide.
User | Count |
---|---|
141 | |
113 | |
104 | |
77 | |
64 |
User | Count |
---|---|
135 | |
123 | |
101 | |
71 | |
61 |