Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
smpa01
Super User
Super User

How to pass on a parameter to a SSAS query

Does anyone know how to pass on a parameter to a SSAS query?

My current query is following

 

AnalysisServices.Database("powerbi://api.powerbi.com/v1.0/myorg/XYZ", "Budget", [Query="EVALUATE
VAR _1 = 2021
VAR _01 = 4
VAR _2 =
    FILTER (
        dx,
        dx[DataYear] = _1
            && dx[DataCAT] = "Forecast"
    )
............
........
", Implementation="2.0"])

 

I want to pass on a parameterized value to VAR _01 like following

 

let 
    var1=4,
    Source = AnalysisServices.Database("powerbi://api.powerbi.com/v1.0/myorg/XYZ", "Budget", [Query="EVALUATE
VAR _1 = 2021
VAR _01 = var1
VAR _2 =
    FILTER (
        dx,
        dx[DataYear] = _1
            && dx[DataCAT] = "Forecast"
    )
............
........
", Implementation="2.0"])
in 
  Source

 

Is it possible?

so far I have tried

 

let 
    var1=4,
    Source = AnalysisServices.Database("powerbi://api.powerbi.com/v1.0/myorg/XYZ", "Budget", [Query="EVALUATE
VAR _1 = 2021
VAR _01 = """&var1&"""
VAR _2 =
    FILTER (
        dx,
        dx[DataYear] = _1
            && dx[DataCAT] = "Forecast"
    )
............
........
", Implementation="2.0"])
in 
  Source

 

but it did not work.

Thank you in advance.

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
smpa01
Super User
Super User

Found it

var1=4,
var2=Text.From(var1)
VAR _01 = CONVERT("""&var2&""",INTEGER)
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

3 REPLIES 3
smpa01
Super User
Super User

Found it

var1=4,
var2=Text.From(var1)
VAR _01 = CONVERT("""&var2&""",INTEGER)
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

great, just what I needed!

Thank you for share the finding😉.

 

Paul Zheng _ Community Support Team

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.