Forum Discussion
DAX Lookup value
- 6 years ago
Hi, John_Peter
Try to create calculated column as below:
Column = [Amount] - (CALCULATE(SUM('Cost'[Value]),FILTER('Cost','Cost'[Attribute] = "Cost"&LOOKUPVALUE('Customers'[Currency],Customers[Customer],'Sales'[Product]) && 'Sales'[Date]>='Cost'[From] && 'Sales'[Date]<='Cost'[To]))*[Qty])It shows as below:
Here is a demo:
pbix attach
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
So, you can use LOOKUPVALUE for the currency. You would then do something like:
Column =
VAR __Currency = LOOOKUPVALUE('Customers'[Currency],'Customers'[Customer],'Sales'[Customer])
VAR __Table =
FILTER(
'Cost',
'Sales'[Date] >= 'Cost'[From] &&
'Sales'[Date]<='Cost'[To] &&
'Sales'[Product] = 'Cost'[Product]
)
RETURN
SWITCH(__Currency),
"USD",MAXX(__Table,[CostUSD]),
"CAD",MAXX(__Table,[CostCAD]),
BLANK()
)
Greg_Deckler
Thanks for the response,
I am brand new in the world of PowerBI, can you tell me if it is better to create a table to put all my calculated Column? if so how do i go about creating this dimension or table?
I really appreciate your help.
- Greg_Deckler6 years agoCommunity Champion
I would generally not create a separate table for just calculated columns. You generally put calculated columns into your fact table or the table where it makes the most amount of sense.
For you other question, you create new tables by using the New Table button in the ribbon. Depends on the version of the ribbon you are using where this is located. In the new ribbon, this is found under Modeling and it is in the Calculations area.