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
SamGibbs1
Frequent Visitor

Filtering lookup

Hi,

 

I am trying to look up values using DAX, but only where a text entry is = to something. I have the look up element working:

 

RTSG_Costs = LOOKUPVALUE(RTSGMatrix[RTSGAmount],RTSGMatrix[Award],LOOKUPVALUE(StudentDetails[Award],StudentDetails[SITS_StudentNumber],StudentYearsActive[SITS_StudentNumber]),RTSGMatrix[AcademicYear],StudentYearsActive[AcademicYear])*StudentYearsActive[MonthDecimal]

 

If I was working in excel I would add something like:

IF(RTSGMatrix[annualised]="Annual", FORMULA AS ABOVE, 0)

so that only look ups from entries that have 'Annual' against them are pulled through, with the rest returning a 0 value.

 

1 ACCEPTED SOLUTION

@SamGibbs1,

Firstly, please ensure that you use "New Column" option in Power BI Desktop to create calculated columns.
1.PNG

Secondly, please split the above DAX formula into multiple formulas to better troubleshoot the issue.

Col2=LOOKUPVALUE(RTSGMatrix[RTSGAmount],RTSGMatrix[Award],LOOKUPVALUE(StudentDetails[Award],StudentDetails[SITS_StudentNumber],StudentYearsActive[SITS_StudentNumber]),RTSGMatrix[AcademicYear],StudentYearsActive[AcademicYear])*StudentYearsActive[MonthDecimal]
Col1=LOOKUPVALUE(RTSGMatrix[RTSGPaidLump_or_Annual],RTSGMatrix[Award],LOOKUPVALUE(StudentDetails[Award],StudentDetails[SITS_StudentNumber],StudentYearsActive[SITS_StudentNumber]))
LastColumn = IF(TableName[Col1]="Annual",TableName[Col2],0)


If you still get errors, please share sample data of your table and post expected result here following the guide in this thread:https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
SamGibbs1
Frequent Visitor

Hi,

 

To expand a bit further I have tried this:

RTSG_Costs = If(LOOKUPVALUE(RTSGMatrix[RTSGPaidLump_or_Annual],RTSGMatrix[Award],LOOKUPVALUE(StudentDetails[Award],StudentDetails[SITS_StudentNumber],StudentYearsActive[SITS_StudentNumber]))="Annual",LOOKUPVALUE(RTSGMatrix[RTSGAmount],RTSGMatrix[Award],LOOKUPVALUE(StudentDetails[Award],StudentDetails[SITS_StudentNumber],StudentYearsActive[SITS_StudentNumber]),RTSGMatrix[AcademicYear],StudentYearsActive[AcademicYear])*StudentYearsActive[MonthDecimal],0)

 

but it returns an error "A table of multiple values was supplied where a single value was expected". I am guessing this is due to the IF statement returning multiple records to check?

 

 

@SamGibbs1,

Firstly, please ensure that you use "New Column" option in Power BI Desktop to create calculated columns.
1.PNG

Secondly, please split the above DAX formula into multiple formulas to better troubleshoot the issue.

Col2=LOOKUPVALUE(RTSGMatrix[RTSGAmount],RTSGMatrix[Award],LOOKUPVALUE(StudentDetails[Award],StudentDetails[SITS_StudentNumber],StudentYearsActive[SITS_StudentNumber]),RTSGMatrix[AcademicYear],StudentYearsActive[AcademicYear])*StudentYearsActive[MonthDecimal]
Col1=LOOKUPVALUE(RTSGMatrix[RTSGPaidLump_or_Annual],RTSGMatrix[Award],LOOKUPVALUE(StudentDetails[Award],StudentDetails[SITS_StudentNumber],StudentYearsActive[SITS_StudentNumber]))
LastColumn = IF(TableName[Col1]="Annual",TableName[Col2],0)


If you still get errors, please share sample data of your table and post expected result here following the guide in this thread:https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.