10 Replies Latest reply: Apr 21, 2017 5:51 AM by Amit Saini

# Expression Help ???

Hi Folks,

I need help in below logic.

I'm having shift wise stacked bar chart which is showing "Pieces Produced" across 3 shifts , like below:

Dim : 1. Date

2. Shift_Name

Expression:

Pieces Produced : =num(Count(DISTINCT  Serial))

Now I have to calculate "Total Pieces Produced " and the logic for this should be :

TOTAL PIECES PRODUCED = Above Calculation of Pieces Produced + [NO CAQ SCRAP FLAG]

So condition for [NO CAQ SCRAP FLAG] is vNScrapFlag =SUM( {\$<Type_Name = {'Scrap'},Production = {'NoCAQ'}>} Quantity)

I'm trying below expression to achieve Total Pieces , but it not working as expected :

=num(Count(DISTINCT  Serial)) + vNScrapFlag

See below:

As you can see above in Scrap Produced graph , we are having count "2" in Spat shift and "16" in Nacht Shift , so in bar chart of Total Pieces Produced it should add 2 to 243 Spat shift and 16 to 302 Nacht Shift.

By using =num(Count(DISTINCT  Serial)) + vNScrapFlag , it is adding "18" to all the shifts which is wrong. The correct Output should be as marked in yellow circle.

I hope I'n clear here!

Please suggest how I can achieve this.

Attached is demo qvw.

Thanks,

AS

• ###### Re: Expression Help ???

Any Suggestions???

Thanks,

AS

• ###### Re: Expression Help ???

Are you expecting changes over here - Total Pieces Produced stacked by shift ??

• ###### Re: Expression Help ???

Yes Anil.

Thanks,

AS

• ###### Re: Expression Help ???

Is this you are expecting

I have removed Shift_Name and i added

Calc. Dimension:

=ValueList('Früh','Nacht','Spät')

Expression:

If(ValueList('Früh','Nacht','Spät') = 'Nacht',num(SUM( {\$<Shift_Name = {'Nacht'}, Type_Name = {'Scrap'}>} Quantity)), If(ValueList('Früh','Nacht','Spät') = 'Spät',

num(SUM( {\$<Type_Name = {'Scrap'}, Shift_Name = {'Spät'}>} Quantity)),

If(ValueList('Früh','Nacht','Spät') = 'Früh',num(Count(DISTINCT {<Shift_Name = {'Früh'}>} Serial)))))

• ###### Re: Expression Help ???

Hi Anil,

Thank you!

I will try this also and update you.

But I got the solution by using below expression:

num(Count(DISTINCT  Serial)) + SUM({\$<Type_Name = {"Scrap"}>} Quantity) -SUM( {\$<Type_Name = {'Scrap'},Production = {'CAQ'}>} Quantity)

Thanks,

AS

• ###### Re: Expression Help ???

Good, And this expression gives me this. Is this you are expecting??

• ###### Re: Expression Help ???

Yes Anil!

Thanks,

AS

• ###### Re: Expression Help ???

Haha, I thought that is x not the + . Anyway, Thanks for coming back

• ###### Re: Expression Help ???

Thanks,

AS

• ###### Re: Expression Help ???

Hi,

The shared qvw file shows the same result as you want?