Forum Discussion
LastNonBlank Value
Hi,
I have attached a link to my pbix file.
I have tried writing a measure that returns the last non blank value for Team A, which is 2 but I keep running into different error messages with each variation I try.
It is a simple measure but its getting the better of me - can anyone help?
Thanks
Hello ArchStanton
Please find the below DAX measure for your requirementTeam A Last ValueCALCULATE(LASTNONBLANKVALUE( Sheet1[KPI],Sum(Sheet1[KPI])),FILTER(Sheet1,Sheet1[Area] = "Team A") )
Screenshot BelowHope it will help you.
Regards
sanalytics
If it is your solution then please like and accept it as solution
Hello ArchStanton
The discrepancy of 36 arises due to the last non-blank value of Team C being 12, appearing three times, as expected.
If the last non-blank value for each team member is the maximum among other quarters' KPI values, use the following DAX measure:
lastNonBlankValue =CALCULATE(LASTNONBLANKVALUE( Sheet1[KPI],MAXX( Sheet1,[KPI]) ),FILTER(Sheet1,Sheet1[Area] = "Team C") )If the last non-blank value of every team member is not the maximum, apply this alternative DAX measure2nd Measure =VAR _MaxIndex =CALCULATE(MAX( Sheet1[Index] ),FILTER(ALL( Sheet1[KPI] ),Sheet1[KPI] <> BLANK()) )VAR _Result =CALCULATE(SUM( Sheet1[KPI] ),FILTER(ALL( Sheet1[Index] ),Sheet1[Index] = _MaxIndex),Sheet1[Area] = "Team C" )RETURN_ResultI trust this clarifies the logic. Please find the attached PBIX file alsoRegardssanalyticsIf it is your solution then please like and accept it as solution
6 Replies
- sanalyticsSuper User
Hello ArchStanton
Please find the below DAX measure for your requirementTeam A Last ValueCALCULATE(LASTNONBLANKVALUE( Sheet1[KPI],Sum(Sheet1[KPI])),FILTER(Sheet1,Sheet1[Area] = "Team A") )
Screenshot BelowHope it will help you.
Regards
sanalytics
If it is your solution then please like and accept it as solution
- ArchStantonPower Participant
Hi,
I noticed it works for Team A & B but Team C produces 36 instead of 12.Where is that number coming from?
- sanalyticsSuper User
Hello ArchStanton
The discrepancy of 36 arises due to the last non-blank value of Team C being 12, appearing three times, as expected.
If the last non-blank value for each team member is the maximum among other quarters' KPI values, use the following DAX measure:
lastNonBlankValue =CALCULATE(LASTNONBLANKVALUE( Sheet1[KPI],MAXX( Sheet1,[KPI]) ),FILTER(Sheet1,Sheet1[Area] = "Team C") )If the last non-blank value of every team member is not the maximum, apply this alternative DAX measure2nd Measure =VAR _MaxIndex =CALCULATE(MAX( Sheet1[Index] ),FILTER(ALL( Sheet1[KPI] ),Sheet1[KPI] <> BLANK()) )VAR _Result =CALCULATE(SUM( Sheet1[KPI] ),FILTER(ALL( Sheet1[Index] ),Sheet1[Index] = _MaxIndex),Sheet1[Area] = "Team C" )RETURN_ResultI trust this clarifies the logic. Please find the attached PBIX file alsoRegardssanalyticsIf it is your solution then please like and accept it as solution
- ArchStantonPower Participant
Perfect, thanks a lot!