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.
Something like this?
Daniel_PowerBI , yes please. this what i'm trying to do. Thanks
- Daniel_PowerBI2 years agoAdvocate I
Perfect,
Connect your Tables like this
Visual like this:
and here the mesure for the $:
$ = SUM('Price'[Price])* SUM(Sales[Sales aMount])Let me know if it works