US and Worldwide: +1 (866) 660-7555
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Create an UDF in Pentaho Workbench Schema

  1. #11
    Join Date
    Jan 2013
    Posts
    489

    Default

    The .evaluateScalar call won't give you the value of the dimension member-- it pushes that member into context and evaluates the cell at that intersection.

    To grab the member name (in this case -1, 1), use the Properties function. For example:

    cast( [Store Size in SQFT].CurrentMember.Properties("MEMBER_NAME") as Integer)

    grabs the name of the member from the Store Size dimension and casts it to an Integer.

    You could do something like

    Measures.CA * cast( [Lignes].[SNS_0].CurrentMember.Properties("MEMBER_NAME") as Integer)

    Or, if you will be doing anything more complex with your UDF, you can pass these in as parameters.

  2. #12
    Join Date
    Jan 2013
    Posts
    28

    Default

    Thank you mcampell !!!

    It seems work with negative SNS_0 but I dont understand why it show me only negative value ...


    As you can see in the picture, instead of positive values, I have -0 ...

    I continue to search but If you have an idea...

    Thank you again ! you are very helpfull for me

  3. #13
    Join Date
    Jan 2013
    Posts
    489

    Default

    In the report in your screenshot, the CurrentMember of [Lignes].[SNS_0] is the default member (since it's not explicitly in the query). So you're multiplying the value of the default member (I'm guessing -1) by the measure value for everything. If you crossjoin Lignes in your report you'll probably see a different breakdown.

    Can a Magasin have more than one Lignes?

  4. #14
    Join Date
    Jan 2013
    Posts
    28

    Default

    Yes it can have more than one Lignes!

    AMTNOTLIN_0 is the field that used in "old" [Measures].[CA]:


    This field is in the same table as SNS_0 so I created a level in order to do the crossjoin:


    Is it correct ? so, how can I cross join Lignes in ? I am sorry , I am novice in MDX

    I tried to create a calculated Member like this :


    But I give me error ...
    Last edited by OMDCAPSYS; 10-02-2013 at 08:57 AM.

  5. #15
    Join Date
    Jan 2013
    Posts
    489

    Default

    I was suggesting to crossjoin Lignes.SNS_0 on the report (that is, drag SNS_0 to the left or right of magasins), just to verify that you then get a breakdown you would expect based on the 1/-1 values. If that looks correct to you, we can start thinking about how to get the correct aggregate value when SNS_0 is not explicitly in context.
    Last edited by mcampbell; 10-02-2013 at 01:31 PM.

  6. #16
    Join Date
    Jan 2013
    Posts
    28

    Default

    Very good idea ! When I put SNS_0 with Magasin it's work ! But how can I do without SNS_0 ?


  7. #17
    Join Date
    Jan 2013
    Posts
    489

    Default

    You'll now need to create a calculated member that rolls up the set of SNS_0 members. Something like

    aggregate([Lignes].[SNS_0].members, Measures.[CA_mnt])




  8. #18
    Join Date
    Jan 2013
    Posts
    28

    Default

    I get an error "NaN"...

  9. #19
    Join Date
    Jan 2013
    Posts
    489

    Default

    Can you post the whole stack trace? Also, what does your formula look like now?

  10. #20
    Join Date
    Jan 2013
    Posts
    28

    Default

    In writing you an answer, I've realized a careless mistake.
    That's why I had that "Nan". The error is corrected handling works very well ...


    Thank you for all your help, without it I would not have succeeded

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •