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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
niteshtrehan89
Helper III
Helper III

Displaying two measures in the slicer in the visual

Hi All,

 

I have a urgent requirement in which I have created the two measures. 

Projectvalue= Sum(projectvalue)

Forecast= Sum(forecast)

 

Now i want to plot a bar chart with projectvalue, forecast and both. I have created a table named as Measure having three rows(Projectvalue, Forecast, Both)

 

 

I have created the selected measure for forecast and project value and it working perfecting fine. What to do if I need to showcase both the measure using the Both in the slicer.

 

Selected Measure = SWITCH(TRUE(),SELECTEDVALUE('Measure'[Measure])="Project Value",sum(data[Project Value]),SELECTEDVALUE('Measure'[Measure])="Forecasted Project Value",SUM(data[Forecasted Project Value]),SELECTEDVALUE('Measure'[Measure])="Both",SUM(data[Project Value]) && SUM(data[Forecasted Project Value]))
 
Thanks
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @niteshtrehan89 

According to your description, you want to display the sum of values according to the selection of Slicer, you can try my steps:

  1. Create a table ‘Slicer’ for the Slicer:

v-robertq-msft_0-1604304233316.png

 

  1. Create two measures:
Sum of Project Value =

SWITCH(

    SELECTEDVALUE(Slicer[Name]),

    "Project Value",SUM('Measure'[Project Value]),

    "Forecasted Project Value",BLANK(),

"Both",SUM('Measure'[Project Value]))

 

Sum of Forecasted Project Value =

SWITCH(

    SELECTEDVALUE(Slicer[Name]),

    "Project Value",BLANK(),

    "Forecasted Project Value",SUM('Measure'[Forecasted Project Value]),

"Both",SUM('Measure'[Forecasted Project Value]))

 

  1. Create a slicer and a column chart, like this:

v-robertq-msft_1-1604304233324.png

 

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-robertq-msft
Community Support
Community Support

Hi, @niteshtrehan89 

According to your description, you want to display the sum of values according to the selection of Slicer, you can try my steps:

  1. Create a table ‘Slicer’ for the Slicer:

v-robertq-msft_0-1604304233316.png

 

  1. Create two measures:
Sum of Project Value =

SWITCH(

    SELECTEDVALUE(Slicer[Name]),

    "Project Value",SUM('Measure'[Project Value]),

    "Forecasted Project Value",BLANK(),

"Both",SUM('Measure'[Project Value]))

 

Sum of Forecasted Project Value =

SWITCH(

    SELECTEDVALUE(Slicer[Name]),

    "Project Value",BLANK(),

    "Forecasted Project Value",SUM('Measure'[Forecasted Project Value]),

"Both",SUM('Measure'[Forecasted Project Value]))

 

  1. Create a slicer and a column chart, like this:

v-robertq-msft_1-1604304233324.png

 

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@niteshtrehan89 , measure slicer is the measure itself so only measure can be there.

 

So both measures need to check the value of slicer

 

example

 

Projectvalue =
var _flag = countx(allselected(Measure), 'Measure'[Measure] in {"Project Value","Both"})+0
return
if(_flag>0, sum(data[Project Value]), blank())


Forecast =
var _flag = countx(allselected(Measure), 'Measure'[Measure] in {"Forecasted Project Value","Both"})+0
return
if(_flag>0, sum(data[Forecasted Project Value]), blank())

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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