Forum Discussion
My Matrix Table Keeps Showing More than X rows despite Measures - How to fix?
- 1 year ago
HI,
I am not sure if I understood your question correctly, but in my opinion, only adding top 5 of each store is correctly shown. However, if you still want to show all total, then please try something like below.
Customer top5 by store = VAR BaseTable = ADDCOLUMNS ( CALCULATETABLE ( SUMMARIZE ( Overview, 'Unique Customers'[Customer], 'Unique Stores'[Store] ), REMOVEFILTERS ( 'Unique Customers'[Customer] ), ALLSELECTED ( 'Date'[Year] ) ), "@val", CALCULATE ( [Total Sales], ALLSELECTED ( 'Date'[Year] ) ) ) VAR Result = CALCULATE ( [Total Sales], KEEPFILTERS ( WINDOW ( 1, ABS, 5, ABS, BaseTable, ORDERBY ( [@val], DESC ), , PARTITIONBY ( 'Unique Stores'[Store] ) ) ) ) RETURN IF ( NOT ISINSCOPE ( 'Unique Customers'[Customer] ), [Total Sales], Result )
Hi,
Please try the below and the attached pbix file whether it works.
- remove condition (customer is visible) from filter pane
- add the below measure to the visual.
Customer top5 by store =
VAR BaseTable =
ADDCOLUMNS (
CALCULATETABLE (
SUMMARIZE ( Overview, 'Unique Customers'[Customer], 'Unique Stores'[Store] ),
REMOVEFILTERS ( 'Unique Customers'[Customer] ),
ALLSELECTED ( 'Date'[Year] )
),
"@val", CALCULATE ( [Total Sales], ALLSELECTED ( 'Date'[Year] ) )
)
VAR Result =
CALCULATE (
[Total Sales],
KEEPFILTERS (
WINDOW (
1,
ABS,
5,
ABS,
BaseTable,
ORDERBY ( [@val], DESC ),
,
PARTITIONBY ( 'Unique Stores'[Store] )
)
)
)
RETURN
Result
Hi - thanks for that, it appears that the store subtotal and overall values seem to be inaccurate for your file
as the total should be 381M (based off totalling the data in the excel sheet) - is there a way to fix this? Thanks.
- Jihwan_Kim1 year ago
Super User
HI,
I am not sure if I understood your question correctly, but in my opinion, only adding top 5 of each store is correctly shown. However, if you still want to show all total, then please try something like below.
Customer top5 by store = VAR BaseTable = ADDCOLUMNS ( CALCULATETABLE ( SUMMARIZE ( Overview, 'Unique Customers'[Customer], 'Unique Stores'[Store] ), REMOVEFILTERS ( 'Unique Customers'[Customer] ), ALLSELECTED ( 'Date'[Year] ) ), "@val", CALCULATE ( [Total Sales], ALLSELECTED ( 'Date'[Year] ) ) ) VAR Result = CALCULATE ( [Total Sales], KEEPFILTERS ( WINDOW ( 1, ABS, 5, ABS, BaseTable, ORDERBY ( [@val], DESC ), , PARTITIONBY ( 'Unique Stores'[Store] ) ) ) ) RETURN IF ( NOT ISINSCOPE ( 'Unique Customers'[Customer] ), [Total Sales], Result )