Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MDX Filter Query

Tags:

filter

equals

mdx

I have a query that is trying to filter the results where it equals a certain value. The query belows works fine...

SELECT NON EMPTY {[Date].[Year Number].Members} ON COLUMNS, 
NON EMPTY CROSSJOIN({[ItemCode].[Item Category].Members}, {[Measures].[Net Sales], [Measures].[Total Cost], [Measures].[Profit]}) ON ROWS  
FROM (SELECT Filter([ItemCode].[Item Category].[Item Category].Members, ([Measures].[Net Sales] = 3440.8)) ON COLUMNS FROM [Sales])

...however an identical query but with a different value...

SELECT NON EMPTY {[Date].[Year Number].Members} ON COLUMNS, 
NON EMPTY CROSSJOIN({[ItemCode].[Item Category].Members}, {[Measures].[Net Sales], [Measures].[Total Cost], [Measures].[Profit]}) ON ROWS  
FROM (SELECT Filter([ItemCode].[Item Category].[Item Category].Members, ([Measures].[Net Sales] = 41581.65)) ON COLUMNS FROM [Sales])

...doesnt want to work at all. I know they both should work fine as both values exist in the cube, and it isnt just this value that doesnt work, it is quite a few, and as far as I can see there is no pattern.

like image 300
ATB Avatar asked Dec 28 '25 01:12

ATB


1 Answers

I'd suggest checking the data type for [Net Sales] if it's a floating point type e.g. Double then searching for an exact value may not work. i.e. the 41581.65 value may be 41581.6500001 in the database.

If you change the data types to fixed precision e.g. Currency then the queries may work. Have a look at this link for the many benfits of money

like image 166
Craig Avatar answered Dec 30 '25 23:12

Craig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!