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
Anonymous
Not applicable

how to get value from another table

Hi i have two table, one saletypsinfo like this:

datesalestype
2021-01-01new year sales
2021-01-09No sales
2021-02-15feb sales
2021-02-20No sales
2021-03-01Season sales

 

and a facttables with date and sales like this:

datesales
2021-01-01100
2021-01-02150
2021-01-03400
2021-01-04200
2021-01-05400
2021-01-06150
2021-01-07150
2021-01-08400
2021-01-09400
2021-01-10100
2021-01-11400
2021-01-12400
2021-02-15200
2021-02-16400
2021-02-17150
2021-02-18400
2021-02-19200
2021-02-20400
2021-02-21400
2021-02-22400
2021-02-23100
2021-03-01400
2021-03-02400
2021-03-03200
2021-03-04400

 

I want to add the salestype column into the facttables to track what kind of sales is it, do anyone have idea?

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

Agree with the solution given by @amitchandak  and do the following test:

new column = 
var _max = maxx(filter(Saletypes, Saletypes[date] <='Fact'[date]),Saletypes[date])
return
maxx(filter(Saletypes, Saletypes[date] = _Max ),Saletypes[salestype])

v-henryk-mstf_0-1621835750438.png


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

 

Best Regards,
Henry

 

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

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

Agree with the solution given by @amitchandak  and do the following test:

new column = 
var _max = maxx(filter(Saletypes, Saletypes[date] <='Fact'[date]),Saletypes[date])
return
maxx(filter(Saletypes, Saletypes[date] = _Max ),Saletypes[salestype])

v-henryk-mstf_0-1621835750438.png


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

 

Best Regards,
Henry

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you it works fine with your solution.

jmontes1810
Frequent Visitor

I think a LookUpValue in a new column on your facttables table is a easier way to do it.
Something like this....

New Column = LOOKUPVALUE(saletype[saletypsinfo],date[saletypsinfo],date[facttables])
 
*slaestypeinfo must cotain unique values in date column to work
amitchandak
Super User
Super User

@Anonymous , Try a new column like this in sales table sales

 

new column =
var _max = maxx(filter(saletypsinfo, saletypsinfo[Date] <=sales[Date]),saletypsinfo[Date])
return
maxx(filter(saletypsinfo, saletypsinfo[Date] = _Max ),saletypsinfo[salestype])

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.