Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8042371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:33:22+00:00 2026-06-05T04:33:22+00:00

I have 3 variables which will be conditional when @path is not NULL i.e

  • 0

I have 3 variables which will be conditional when @path is not NULL i.e
@serverName,@analysisDB,@cubeName. Hence I used a CASE statement in the above SELECT statement. Similarly, for @path is not NULL the @cubename also needs to be conditional for LVL5.L5_CubeName (see REPLACE statement) but its inside a REPLACE statement and the CASE block becomes too complicated for the same. How do I write it if I want to do something like

CASE WHEN @path!='' THEN @cubeName ELSE LVL5.L5_CubeName in the REPLACE statement
SELECT LVL5.L5_Id,        
         CASE WHEN @path!='' THEN @serverName ELSE LVL5.L5_ServerName END [AnalysisServer],        
         CASE WHEN @path!='' THEN @analysisDB ELSE LVL5.L5_AnalysisDatabase END [AnalysisDatabase],        
         REPLACE(REPLACE(REPLACE(LVL5.L5_MDXQuery,'@@Level1',ISNULL(@lvl1DataVal,'')),    
         '@@Level2',ISNULL(@lvl2DataVal,'')),'@@CubeName',ISNULL(@cubeName,'')) [MDXQuery],         
         LVL5.L5_ReplaceMDX [ReplaceMDX],      
         LVL5.L5_RefreshDate [RefreshDate],      
         LVL5.L5_ReportAttribute [ReportAttribute],      
         LVL5.L5_ReportTitle [ReportTitle]           
  FROM   Report_SR_Level5 [LVL5]                  
  WHERE L4_ID = @L4_ID ORDER BY LVL5.L5_DisplayOrder 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:33:24+00:00Added an answer on June 5, 2026 at 4:33 am

    Something like this:

    CASE WHEN @path is not null or @path != '' 
    THEN REPLACE(REPLACE(REPLACE(LVL5.L5_MDXQuery,'@@Level1',
    ISNULL(@lvl1DataVal,'')),'@@Level2',ISNULL(@lvl2DataVal,'')),'@@CubeName',
    ISNULL(@cubeName,'')) [MDXQuery]
    ELSE Somethingelse END cubedata
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two string variables which are both file paths. The code that worked
I have been looking at LESS ( http://lesscss.org/ ) which adds variables and macro
I have global static variables in a C library, which generate exceptions in a
I have a url which has some get variables in it like: domain.com/recover?email=my@email.com&token=abc123 inside
I have this ingredients array which contains multiple variables (like name, icon, value etc.).
I have an IOS application which uses environment variables and am able to set
I have a Dictionary which I am comparing to another Dictionary (variables typed as
I have an irregular mesh which is described by two variables - a faces
I have a bunch of variables I want to display of which some are
I have a function which evaluates terms of a polynomial in several variables. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.