# Workaround for TRUE/FALSE Expression error



## KnifeandFork (Jan 9, 2014)

Hi all!

I'm desperately trying to get PowerPivot to count the number of 'L's in a column. L itself is a measure, which returns 'L' for stores which have not bought in over a year (and are therefore Lost) and blank for all other cases. When I try the following function:

=calculate(DISTINCTCOUNT([Store]),[Lost]="L")

I get the following error:

Calculation error in measure 'Table1 1'[98cc8508-821c-4611-9777-c96938814971]: A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

The original source file is structured as follows, so I cannot do it directly in the file, as Quarters are in rows and not columns:

CountryStoreBrandQuarterSalesArmeniaaXQ110ArmeniabYQ120ArmeniacYQ127ArmeniaaYQ174ArmeniacXQ1206ArmeniaaXQ260ArmeniabYQ2215ArmeniacXQ2191ArmeniadYQ2197ArmeniaeZQ2189

<tbody>

</tbody>

Any ideas?

Thanks!


----------



## Art15651 (Jan 9, 2014)

Don't make "L" a Measure. Instead, make it a new column using an IF statement and populating it with "L" or "" depending on your criteria. Then you just FILTER on the new column.


----------



## KnifeandFork (Jan 9, 2014)

Art15651 said:


> Don't make "L" a Measure. Instead, make it a new column using an IF statement and populating it with "L" or "" depending on your criteria. Then you just FILTER on the new column.




Thanks for your suggestion. The reason I haven't done this is because, as quarters are not in columns but rows, it would mean for each row referencing back to the previous quarter sales for that store, the next column two quarters back, etc... and then including yet another column with the totals. Not to mention that as each country has repeated entries for each quarter each time there's sales for every type of brand, the past values would also have to reference the brand. As I have close to 1 MM rows, this isn't really feasible.

I'd need to do something like:

CountryStoreBrandQuarterSalesQuarter Ago & Brand ConcatQuarter Ago Sales2 Quarter Ago & Brand Concat2 Quarter Ago Sales3 Quarter Ago & Brand Concat3 Quarter Ago Salesetc…SumLost?ArmeniaaXQ110reference to previous brand and quarterArmeniabYQ120ArmeniacYQ184ArmeniaaYQ1244ArmeniacXQ1194ArmeniaaXQ2341ArmeniabYQ2237ArmeniacXQ2165ArmeniadYQ2298ArmeniaeZQ230

<tbody>

</tbody>


----------

