Forum Discussion
Create a dynamic table from a slicer
- 2 years ago
Hi Community
I was able to solve this
Step 1: Create a measure for total amount
Total =
SUMX (
Table1,
Table1[Amount]
)Step 2: Create a Paremet (From 0 to 1, incresing by 0.1)
Resulting in:
Percent = GENERATESERIES(0, 1, 0.1)Percent Value = SELECTEDVALUE('Percent'[Percent])Step 3: Create a table to include "Other" itemTop Items =UNION(VALUES(Table1[Item]),ROW("Item","Other"))Step 4: Create a measure to rank items in new tableItem Ranking Top =
IF (
NOT (
ISBLANK ( [Total] )
),
IF (
ISINSCOPE ( 'Top Items'[Item] ),
RANKX (
FILTER (
ALLSELECTED ( 'Top Items'[Item] ),
NOT (
ISBLANK ( [Total] )
)
),
[Total]
)
)
)Step 5: Create a measure to obtain the maximum ranking of Step 4Max Ranking Top =
MAXX (
ALLSELECTED ( 'Top Items'[Item] ),
[Item Ranking Top]
)Step 6: Create a measure to obtain the Top N SpendTop NSpend =
VAR TopItems =
TOPN (
'Percent'[Percent Value] * [Max Ranking Top],
ALLSELECTED ( 'Top Items' ),
[Total]
)
VAR Allspend =
CALCULATE (
[Total],
ALLSELECTED ( 'Top Items' )
)
VAR Otherspend =
Allspend
- CALCULATE (
[Total],
TopItems
)
VAR TopNspend =
CALCULATE (
[Total],
KEEPFILTERS ( TopItems )
)
VAR currentitems =
SELECTEDVALUE ( 'Top Items'[Item] )
RETURN
IF (
currentitems = "Other",
Otherspend,
TopNspend
)Step 7: Create a ranking to order the resultsRanking =
IF (
[Top NSpend] > 0,
RANKX (
FILTER (
ALLSELECTED ( 'Top Items'[Item] ),
NOT (
ISBLANK ( [Total] )
)
),
[Total]
)
)Now, to create the required visualisation, I had:- Included a filter for the parameter (single value)
- Included a filter for year (List)
- Included a filter for Location (List)
- Include a filter for Description (List)
- Included a "Line and clustered column chart"
- Include field "Item" from table "Top Items" in "X-axis"
- Include measure "Top NSpend" in "Column y-axis"
- Include measure "Ranking" in "Line y-axis"
- Sort axis by "Ranking" and "Sort ascending"
Now, below my results replicating excalty what I required in my initial post
Unfortunatelly, I am not able to upload the PBIX file. Otherwise, happy to share the file
Idrissshatila your suggestion/recommendation did not help me at all in getting this solved
Regards,
Carlos
Hi Community
I was able to solve this
Step 1: Create a measure for total amount
Total =
SUMX (
Table1,
Table1[Amount]
)
Step 2: Create a Paremet (From 0 to 1, incresing by 0.1)
Resulting in:
IF (
NOT (
ISBLANK ( [Total] )
),
IF (
ISINSCOPE ( 'Top Items'[Item] ),
RANKX (
FILTER (
ALLSELECTED ( 'Top Items'[Item] ),
NOT (
ISBLANK ( [Total] )
)
),
[Total]
)
)
)
MAXX (
ALLSELECTED ( 'Top Items'[Item] ),
[Item Ranking Top]
)
VAR TopItems =
TOPN (
'Percent'[Percent Value] * [Max Ranking Top],
ALLSELECTED ( 'Top Items' ),
[Total]
)
VAR Allspend =
CALCULATE (
[Total],
ALLSELECTED ( 'Top Items' )
)
VAR Otherspend =
Allspend
- CALCULATE (
[Total],
TopItems
)
VAR TopNspend =
CALCULATE (
[Total],
KEEPFILTERS ( TopItems )
)
VAR currentitems =
SELECTEDVALUE ( 'Top Items'[Item] )
RETURN
IF (
currentitems = "Other",
Otherspend,
TopNspend
)
IF (
[Top NSpend] > 0,
RANKX (
FILTER (
ALLSELECTED ( 'Top Items'[Item] ),
NOT (
ISBLANK ( [Total] )
)
),
[Total]
)
)
- Included a filter for the parameter (single value)
- Included a filter for year (List)
- Included a filter for Location (List)
- Include a filter for Description (List)
- Included a "Line and clustered column chart"
- Include field "Item" from table "Top Items" in "X-axis"
- Include measure "Top NSpend" in "Column y-axis"
- Include measure "Ranking" in "Line y-axis"
- Sort axis by "Ranking" and "Sort ascending"
Now, below my results replicating excalty what I required in my initial post
Unfortunatelly, I am not able to upload the PBIX file. Otherwise, happy to share the file
Idrissshatila your suggestion/recommendation did not help me at all in getting this solved
Regards,
Carlos