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.
Hi,
I want to perform a regression analysis with R script. I used mtcars dataset as test data. My regression formula is basically: lmod<-lm(mpg~cyl+wt+hp)
Also wanted to enable users to choose which variables to use as y (predicted) variable. To do so created a parameter as YVariable which works on a list query consists of column (variable) names. So predicted variable is set via parameter.
Note: I put a null row in list query.
If YVVariable(mpg) formula is;
lmod<-lm("&Text.From(YVariable)&"~cyl+wt+hp,mtcars)
lmod<-lm(mpg~cyl+wt+hp,mtcars)
And it works!
My next challange is to do the same thing for independent variables (such as cyl, wt, hp ...)
To do so I created parameters called Independent1,2,3...
lmod<-lm("&Text.From(YVariable)&"~"&Text.From(Independent1)&"+"&Text.From(Independent2)&"+"&Text.From(Independent3)&",mtcars)
In this case if
Independent1(hp)
Independent1(wt)
Independent1(cyl) formula will be lmod<-lm(mpg~cyl+wt+hp)
But I want to be able to set the formula as lmod<-lm(mpg~cyl+wt) (without hp) In this case Independent3() should be null.
But if one of the Independent parameters is null - Independent1() - BI returns following error,
Expression.Error: We cannot convert the value null to type Text.
Details:
Value=
Type=Type
What could be Done? Any ideas?
Thanks!
Hi @Anonymous ,
can you provide your pbix file?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
94 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |