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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
UsePowerBI
Post Prodigy
Post Prodigy

How to remove duplicates from a variable?

Hello

 

I have a MAX calculation stored in a variable:

VAR a = 

CALCULATE (
MAX ( 'Table1'[Column1] ),
'Table2'[Column2] = EARLIER ( Table1[Column3] )
RETURN
LOOKUPVALUE (
'Table1'[Column4],
'Table1'[Column5], Table2[Column3],
'Table1'[Column1].[Date], a
)
 
Because there are duplicates, it seems that this VAR stores a list of duplicate values instead of one value and I get the error of 'table returned when expected single value'.
 
How can I overcome this?
 
Thanks
2 REPLIES 2
amitchandak
Super User
Super User

@UsePowerBI ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Appreciate your Kudos.

AlB
Super User
Super User

Hi @UsePowerBI 

What do you mean it stores duplicate values? MAX( ) is a scalar function and will thus return one value only. That is what you 're assigning to the variable (assuming the the code is missing a closing parenthesis right before the RETURN)

LOOKUPVALUE is also a scalar function and will return only one value. If multiple rows match the search values and in all cases Result_Column values are identical then that value is returned. However, if Result_Column returns different values an error is returned. Perhaps that is what's happening

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.