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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

slicers for weighted column

Hey community! I hope there is someone out there who can help me with this problem. I will try to explain it as clear as possible.

 

I am currently building an assesment model to analyse companies by a set of criteria. In Rstudio I made a simple data frame with those criteria (normalised) and created a column called "score" where i weighted these criteria. the calculation is really simple:

 

```{r weigh criteria}
DF$score<- (DF$reviews*25) + (DF$visits*25) + (DF$desirability*20) + (DF$followercount*15) + (DF$tweets*5) + (DF$size*5) #assigning weights
```

here is what the dataframe looks like:

robin_wijs_0-1637661161803.png

 

I made a simple dashboard in powerBI where it shows which company scores the highest according to my weighted criteria.

PAM0.5.pdf

now here is my question: 

instead of having a column with static data, I want to have slicers on my report where users can modify the weights per criteria, and the score gets affected by it. I tried making a new slicer and use DAX to make a "what if" function, but when I got the error that the value is not agrregated. i don't want the value to be aggregated because the data points are unique per company. but maybe I'm going about this the complete wrong way. I have experience in R, but this is the first time making a report in Power BI

I appreciate all your tips and feedback! 

Kind regards 

 

 

 

Use what-if parameters to visualize variables - Power BI | Microsoft Docs

 

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

Sounds like you should use the SELECTEDVALUE function to get the value the user has selected from the slicer.

So, something like:

Score = 
VAR _ReviewWeight = SELECTEDVALUE('Review Weight'[Weight])
// etc for all weights
VAR _Result = 
SUMX(
    'Table',
    ('Table'[reviews * _ReviewWeight) + etc..
)
RETURN
    _Result

You can have a second parameter in SELECTEDVALUE, which is the value to use when the user doesn;t make a selection.  You could set that to your default values.

VAR _ReviewWeight = SELECTEDVALUE('Review Weight'[Weight], 25)

 

View solution in original post

2 REPLIES 2
PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

Sounds like you should use the SELECTEDVALUE function to get the value the user has selected from the slicer.

So, something like:

Score = 
VAR _ReviewWeight = SELECTEDVALUE('Review Weight'[Weight])
// etc for all weights
VAR _Result = 
SUMX(
    'Table',
    ('Table'[reviews * _ReviewWeight) + etc..
)
RETURN
    _Result

You can have a second parameter in SELECTEDVALUE, which is the value to use when the user doesn;t make a selection.  You could set that to your default values.

VAR _ReviewWeight = SELECTEDVALUE('Review Weight'[Weight], 25)

 

Anonymous
Not applicable

Can you give a little context on some of these variables? Like how do we include the weight column in this DAX if the weight hasn't been selected by user?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors