Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jouni900
Frequent Visitor

Dynamic measures with two slicers

Hi,

 

I have a dashboard where there is a matrix visual and a stacked bar chart in a time series format.  My measures are all related to volume and I have a slicer for the matrix where there are two selections: 1) Monthly and 2) YTD. For the time series chart I have a slicer where there is possible to choose against which benchmark the current volume is being measured. In my case there are three selections: against previous year, budget and a forecast on a monthly level.

 

I would like to improve the content of the report in the following way:

 

Matrix visual: I would have a slicer with two selections "Volume" and "Sales". If I choose either of them, then using the existing slicer, I can furthermore choose whether I want to look it on a Monthly or YTD level. 

 

Time series: The " Volume" & "Sales" slicer would change the unit of measure and then I could look e.g. Sales agains budget or previous year as I currently do with volume.

 

Is this possible to implement? I could of course add the Sales as an option to the current slicers selections but is there other way where I would simply could add a new slicer where I have Volume and Sales as options and based on the selection the measures in the visuals would change accordingly?

3 REPLIES 3
Sahir_Maharaj
Super User
Super User

Hello @Jouni900,

 

1. Yes, you would need to duplicate the line for all measures that you have. For example, you could create separate measures for Actuals, To PY, Budget, and Forecast, each with its own IF statement based on the selected value of the "Volume" or "Sales" slicer.

 

2.  To connect the "Volume" and "Sales" selection to the other slicer where you have a selection between "Monthly and YTD", you could create a measure that uses the SWITCH function to switch between the different measures based on the selected values of both slicers:

Selected Measure = 
VAR VolumeSelected = SELECTEDVALUE('Slicer'[Selection])
VAR TimeSelected = SELECTEDVALUE('TimeSlicer'[Selection])
RETURN
SWITCH(TRUE(),
    VolumeSelected = "Volume" && TimeSelected = "Monthly", [Monthly Volume Measure],
    VolumeSelected = "Volume" && TimeSelected = "YTD", [YTD Volume Measure],
    VolumeSelected = "Sales" && TimeSelected = "Monthly", [Monthly Sales Measure],
    VolumeSelected = "Sales" && TimeSelected = "YTD", [YTD Sales Measure],
    BLANK()
)

 

Let me know if you might need further assistance!


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
Sahir_Maharaj
Super User
Super User

Hello @Jouni900,

 

To do this, you will need to create two new measures, one for "Volume" and one for "Sales". These measures will use the same underlying data as your existing measures, but will be calculated differently depending on the selection in the new slicer.

 

Volume = IF(SELECTEDVALUE('Slicer'[Selection]) = "Volume", [Existing Volume Measure], BLANK())

 

Sales = IF(SELECTEDVALUE('Slicer'[Selection]) = "Sales", [Existing Sales Measure], BLANK())

 

Once you have created these measures, you can use them in your visuals instead of the existing volume and sales measures. You can also use the new slicer to control which measure is displayed in each visual.

 

For the time series chart, you can use the same approach to create measures for each benchmark (e.g. "Previous Year Sales", "Budget Sales", "Forecast Sales"). You can then use a switch statement in your visual to select the appropriate measure based on the selection in the benchmark slicer.

 

This will give you more flexibility in how you display your data, and will make it easier to switch between different measures and benchmarks.

 

Let me know if this works for you.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hi, @Sahir_Maharaj 

 

Thanks for the reply, I was able to progress a bit with it. I have couple follow up questions about the matrix visual

 

1) I have measures such as Actuals, to PY etc in the matrix. Should I duplicate the line for all measures that I have? 

Volume = IF(SELECTEDVALUE('Slicer'[Selection]) = "Volume", [Existing Volume Measure], BLANK())

for Actuals, to PY etc.? 

 

2) How do I connect the "Volume" and "Sales" selection to the other slicer where I have a selection between "Monthly and YTD". I would like that all the measures that I have change to YTD when changed so, so I would not need to include "YTD" measures separately to the matrix.

 

My current solution for the Act is a following. What I am missing at this point is how to tie it to the "Volume" and "Sales" selection

Measures = SWITCH(TRUE(),"Monthly Vol" IN ALLSELECTED('Dashboard table measures'[Selection]),[Total Vol Blank],"YTD Vol" IN ALLSELECTED('Dashboard table measures'[Selection]),[YTD Vol Blank])
 
I appreciate your help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.