- Forums
- Get Help with Power BI
- Desktop
- Service
- Report Server
- Integrations with Files and Services
- Mobile Apps
- Developer
- Let's Talk Data
- Custom Visuals Development Discussion
- Community Support
- Welcome to the Community
- Community Feedback
- Community Help Blog
- Training and Consulting
- Dashboard in a Day
- EdX Specific Training Discussion Forum

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Microsoft Power BI Community
- Forums
- Get Help with Power BI
- Desktop
- Re: Why does my Measure only works on certain rows...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

ringxiii

Frequent Visitor

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-06-2018
08:49 PM

Hello everone,

I'm into my third week of using DAX in PowerBI and stumbled upon this hurdle where my measure only calculates certain rows but not all like what I would have hoped for.

On the screenshow below, "Decline rate next 5 years_dynamic" and "Decline Rate Dynamic_S" are both measures I have created.

"Decline Rate Dynamic_S" is just a score (1 to 5 score) that is assigned to the asset based on the magnitude of "Decline rate next 5 years_dynamic". My problem is that it assigns a score for most of the assets but left out some - see arrow picture below - and this just puzzles me. My intention is for it to assign scores for all the rows/assets.

The code I have written for "Decline Rate Dynamic_S" is

Decline Rate Dynamic_S =

VAR Score1 = CALCULATE(SELECTEDVALUE('Score Tranches Input'[Decline Rate_SA]), 'Score Tranches Input'[Index] = 1)

VAR Score2 = CALCULATE(SELECTEDVALUE('Score Tranches Input'[Decline Rate_SA]), 'Score Tranches Input'[Index] = 2)

VAR Score3 = CALCULATE(SELECTEDVALUE('Score Tranches Input'[Decline Rate_SA]), 'Score Tranches Input'[Index] = 3)

VAR Score4 = CALCULATE(SELECTEDVALUE('Score Tranches Input'[Decline Rate_SA]), 'Score Tranches Input'[Index] = 4)

VAR Score5 = CALCULATE(SELECTEDVALUE('Score Tranches Input'[Decline Rate_SA]), 'Score Tranches Input'[Index] = 5)

RETURN

IF([Decline rate next 5 years_dynamic] <= Score1, 1,

IF([Decline rate next 5 years_dynamic] <= Score2 && [Decline rate next 5 years_dynamic] > Score1, 2,

IF([Decline rate next 5 years_dynamic] <= Score3 && [Decline rate next 5 years_dynamic] > Score2, 3,

IF([Decline rate next 5 years_dynamic] <= Score4 && [Decline rate next 5 years_dynamic] > Score3, 4,

IF([Decline rate next 5 years_dynamic] > Score5, 5)))))

Any help on this would be very much appreciated.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

Jessica_Seiya

Established Member

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-06-2018
09:24 PM

Seems your nest If missing the condition of 4<[Decline rate next 5 years_dynamic] <=5, You can try the following DAX and see if it works

Decline Rate Dynamic_S = VAR Score1 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 1 ) VAR Score2 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 2 ) VAR Score3 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 3 ) VAR Score4 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 4 ) VAR Score5 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 5 ) RETURN IF ( [Decline rate next 5 years_dynamic] <= Score1, 1, IF ( [Decline rate next 5 years_dynamic] <= Score2, 2, IF ( [Decline rate next 5 years_dynamic] <= Score3, 3, IF ( [Decline rate next 5 years_dynamic] <= Score4, 4, 5 ) ) ) )

2 REPLIES 2

Highlighted

Jessica_Seiya

Established Member

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-06-2018
09:24 PM

Seems your nest If missing the condition of 4<[Decline rate next 5 years_dynamic] <=5, You can try the following DAX and see if it works

Decline Rate Dynamic_S = VAR Score1 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 1 ) VAR Score2 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 2 ) VAR Score3 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 3 ) VAR Score4 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 4 ) VAR Score5 = CALCULATE ( SELECTEDVALUE ( 'Score Tranches Input'[Decline Rate_SA] ), 'Score Tranches Input'[Index] = 5 ) RETURN IF ( [Decline rate next 5 years_dynamic] <= Score1, 1, IF ( [Decline rate next 5 years_dynamic] <= Score2, 2, IF ( [Decline rate next 5 years_dynamic] <= Score3, 3, IF ( [Decline rate next 5 years_dynamic] <= Score4, 4, 5 ) ) ) )

ringxiii

Frequent Visitor

Re: Why does my Measure only works on certain rows ?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-06-2018
10:20 PM

That worked ! Thanks a million !