![1698010227_large.pngcharsetUTF-8](https://quantinsightsnetwork.com/wp-content/uploads/2023/10/1698010227_large.png;charset=UTF-8-678x381.png;charset=utf-8)
The objective is to implement a functionality that enables the dynamic modification of the number of bars displayed in the visual, based on the slicer selection, while concurrently altering the axis.
A video demonstration is available on YouTube
Refer below the sample data model
Above data model can be created using GitHub Repository
First we need to create a Numeric Range Paramter called Range.
Next we need to create a Field Parameter called Dynamic Dimension
Then we need to create a calculated column inside Dynamic Dimension table
Metric = [Dynamic Dimension]
Create a sample base measure called Consumed Data
Consumed Data =
VAR _mb =
CALCULATE (
SUM ( Fact_App_usage[ConsumedData] ),
Fact_App_usage[Date] <= TODAY ()
)
VAR _gb =
DIVIDE ( _mb, 1000 )
RETURN
_gb
Create a new measure called Dynamic TopN Measure
Dynamic TopN Measure =
VAR _range = [Range Value]
VAR _byUser =
// Calculating the Top Users based on _range value and Consumed Data
CALCULATE (
[Consumed Data],
KEEPFILTERS ( TOPN ( _range, ALLSELECTED ( Dim_User ), [Consumed Data], DESC ) )
)
VAR _byApp =
// Calculating the Top Apps based on _range value and Consumed Data
CALCULATE (
[Consumed Data],
KEEPFILTERS ( TOPN ( _range, ALLSELECTED ( Dim_App ), [Consumed Data], DESC ) )
)
VAR _result =
// identifying the selected dimension from the field paramter and switching the result
SWITCH (
SELECTEDVALUE ( 'Dynamic Dimension'[Metric], "AppName" ),
"AppName", _byApp,
"UserName", _byUser
)
RETURN
_result
/*The [Consumed Data] measure may be substituted with an alternative measure, provided that the selected measure is capable of interacting with the chosen dimension.*/
The Dynamic Dimension field may now be dragged into the X-axis of the Bar visual, while the newly created measure (Dynamic TopN Measure) may be placed into the Y-axis.
Interaction with the Range and Dynamic Dimension slicers is now possible. The visual will be updated accordingly, based on the selections made. Just ensure the slicer configuration is same as the below screenshot.
I trust that this article has been informative and valuable to you. Your feedback is important to me and I welcome any comments you may have. 😊
Thank You 😎
Be the first to comment