Divide Measure by dimension

K P 61 Reputation points
2022-05-31T18:45:14.827+00:00

Trying Measure/Dimension - but keep getting errs - the latest err is "The currentmember function expects a hierarchy expression for the 1 argument. A member expression was used".
Below is the query. I am trying to divide amount by month number, like Feb is 2 then 100/2, 150 for Mar then 150/3 and so on.
with member [Measures].[MonNums] as [Time].[Calender].[MonthNum].Currentmember.Uniquename
select ([Measures].[Amount]/[Measures].[MonNums]) on columns,
[Time].[Calendar].[Year].&[2022] on rows from [CubeName].

Thank you,

SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,344 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 41,496 Reputation points
    2022-06-01T02:17:31.127+00:00

    Hi @K P ,

    Please try with below code:

    with member [Measures].[MonNums] as INT( [Time].[MonthNum].Currentmember.Uniquename )  
    select ([Measures].[Amount]/[Measures].[MonNums]) on columns,  
     [Time].[Calender].[MonthNum].memberson rows from [CubeName].  
    

    Regards,

    Zoe


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. K P 61 Reputation points
    2022-06-01T16:45:05.997+00:00

    Getting an error "Query (3,1) The members function expects a hierarchy expression for the argument. A member expression was used. & Query (1, 37) The following system error occurred: Type mismatch"

    wrote exact query you are mentioning @ZoeHui-MSFT .

    Thank you
    K

    0 comments No comments

  3. ZoeHui-MSFT 41,496 Reputation points
    2022-06-02T02:13:45.223+00:00

    Hi @K P ,

    Please check below:

    with member [Measures].[MonNums] as  
    [Date].[Month of Year].currentmember.MEMBERVALUE  
    member [Measures].[valuebymonth] as  
    Divide([Measures].[Sales Amount],[Measures].[MonNums])  
    select {[Measures].[Sales Amount],  
    [Measures].[MonNums],  
    [Measures].[valuebymonth] } on columns,  
    [Date].[Calendar].[Month].members on rows  
    from [Adventure Works NEW]  
    Where [Date].[Calendar Year].&[2011]  
    

    207721-image.png

    Regards,

    Zoe


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.