Forum Discussion
how can i write the Lookup functions please
- 2 years ago
Hi david_flu
You did not mention how to calcualte the sales amount but I am assuming it is unit price * kg. If so, try this calc column in your first table:
Sales = VAR __UNIT_PRICE = LOOKUPVALUE ( 'table2'[Unit Price], 'table2'[Regions], 'table1'[Store], 'table2'[Product], 'table1'[Regions] ) RETURN __UNIT_PRICE * 'Table1'[KGs]If this isn't what you're looking for, please elaborate your use case and provide a sample data we can easily copy-paste (not an image) as well as your sample result. Please refer to this sticky post when creating new posts in the future: https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/3332479#M1112153
- 2 years ago
Daniel_PowerBI the solution danextian should work and you can also do this:
add 2 new columns in each table and then set the relationship on these new columns, which will be one to many, one will be on the store/product side table.
//add new column in Sales Table Surrogate Key = SalesTable[Store] & SalesTable[Product] //add new column in Store Product table Surrogate Key = StoreProductTable[Store] & StoreProductTable[Product] //add new measure for sales Sales Measure = SUMX ( SalesTable, SalesTable[Product Sales] & RELATED ( StoreProductTable[Unit Price] ) )and to visualize. use Week/Day/Store column from SalesTable and the measure Sales Measure
Change the column names and table names as per your data model.
Daniel_PowerBI david_flu I'm done with this post, everything is confusing - are you looking for a solution or going to give the suggestions without following the solution? Thank you!
Hi parry2k , I have followed your steps and still struggling with it. as i have mentioned before that i'm very new to this..
The steps i have done was good until the last measure, somehow it can't find the column for the unit price. please advise where i have done wrong.
i have created 2 unique tables for the relationship, 1) StoreTable. 2) ProductTable.
step 1 below is where i created new column from the SalesTable.
setp 2 below is new culomn created from the StoreProductTable
step 3 below is in error as i don't know where i done wrong and it's located in the SalesTable
all tables below
below is the relationships page
Thanks