Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Pavel_Kastner
Contributor II
Contributor II

Current selections and total view in one stacked bar chart

Hi guys,

I need to create a barchart visualisation, which has 2 bars.

1st bar (Current selections) will show percentage of people by their status according to current selections.

2nd bar (Total) will show the same but ignoring the current selections, ie. percentage of people by their status in the whole dataset.

I have created a dimensions called "View" with two values ("Current selections" and "Total") which I use as Dimension 1 in a bar chart. I use Status as the 2nd Dimension.

I use measure definition as follows:

pick(match(View,'Total','Current selections'),

Count({1}distinct ID)/Count({1}distinct total ID),
Count(distinct ID)/Count(distinct total ID)

)

With no active selections, both the bars look the same, that is correct (see snip1).

But when I make some selections, for example specific age and income group, I need the Total bar (the lower one) to stay the same, but it looses the dimensions values, that were excluded by the selections (ie. it doesn't ignore the current selections and it doesn't sum up to 100 %). See snip2.

It works good with the same measure definitions separated in two visualizations (see snip3), but I need to have in one viz together.

Any help is appreciated.

Thanks!

Pavel

Labels (1)
5 Replies
Kushal_Chawda

use below expression for total

Sum(total {1}aggr(Count({1}  distinct ID)/Count({1}distinct total ID),Status))

 

So overall expression goes like below

pick(match(View,'Total','Current selections'),

Sum(total {1}aggr(Count({1}  distinct ID)/Count({1}distinct total ID),Status)),
Count(distinct ID)/Count(distinct total ID)

)

Pavel_Kastner
Contributor II
Contributor II
Author

Hi,

thanks a bunch for the suggestion, but it doesn't seem to work either. See result in attachment.

Pavel

Kushal_Chawda

would you be able to share a sample? make sire that you are using correct dimension in your aggr

Kushal_Chawda

May be I misunderstood. But seems like issue is your synthetic dimension. As you added synthetic(Inline) dimension , It won't exclude the selections. But you can make use of alternate states.

Add all the selections to one alternate state. You may need to add this alternate states to all the measure which you want to work normally on selection.

Then you can use the below expression

pick(match(View,'Total','Current selections'),

Count({1}distinct ID)/Count({1}distinct total ID),
Count(distinct {State1} ID)/Count(distinct {State1}total ID)

)

where State1 is the alternate state you may need to create. 

Pavel_Kastner
Contributor II
Contributor II
Author

Hi,

the alternate states way works great. It didn't occur to me. Thanks a lot!

Anyway, there is still one problem left. We're using the smart search feature, which sets the selection by default to the default state. But if I understand it correctly, now I need to make the selections in the State1 alternate state. Do you think there is a possibility to change the default for the Smart search to alternate state?

Thank you!

Pavel