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

How to return column of a table variable using DAX formula

itemitemsalessalesConsider the following problem: we have two tables: item and sales. Id is a primary key. Suppose we sell last item with some discount (we know nothing about this discount).

 

We want to add the column with the price of the last sold item to the table item. 

 

We are using something like this:

 

Last_price=

Var

     table_variable=FILTER(RELATEDTABLE(Sales);Sales[discount]=1)

Return 

    table_variable[price] 

 

It is not working. But is there a way to return the column using column of the table variable? 

4 REPLIES 4
Nathaniel_C
Super User
Super User

HI @Diligent_ 

 

Does the discount signify it is the last item? If not how do you know it is the last item?
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




We have a discount only if the last item left. In case of item fancy shoes we have a 50 % discount ( it could be 40% or 60% we have no information on the value of the discount)

 

The example stated is Just a problem to illistrate the question of how to reffer to the column of a table variable.

Nathaniel_C
Super User
Super User

Hi @Diligent_ 

 

Would you provide us with a picture of expected output?

 

Thanks,

Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This is the result I want to obtainThis is the result I want to obtain

I am trying to create a new column in the table items with these values inserted. 

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.

Top Solution Authors