Forum Discussion
IoanCosmin
Helper III
8 years agoCalculate where type clause from two different tables
I haven't written DAX in a while and I'm having a bit of a hard time putting this together and I am hoping someone could throw in a suggestion. What I have: Qty Table (a lot more months than Januar...
- 8 years ago
Hi IoanCosmin
Please see the attached file here. Hope it helps
Here are the steps
First I added a Caclulated Column in QtyTable
Month = MONTH ( QtyTable[Date] )
Second, a MEASURE in QtyTable to get the LaborRate for the months
LaborRate = CALCULATE ( VALUES ( RatesTable[Amount] ), FILTER ( RatesTable, SELECTEDVALUE ( QtyTable[Month] ) >= MONTH ( RatesTable[DateFrom] ) && SELECTEDVALUE ( QtyTable[Month] ) <= MONTH ( RatesTable[DateTo] ) && SELECTEDVALUE ( QtyTable[Location] ) = RatesTable[Location] ) )Thirdly a MEASURE to get the RESULT
RESULTT = SUM ( QtyTable[LaborQty] ) * [LaborRate]
Zubair_Muhammad
Community Champion
8 years agoHi IoanCosmin
Yes SelectedValue is a new function. Even I do not have it in Excel 2016
Instead of
SELECTEDVALUE ( Table[column] )
You can also use
IF ( HASONEVALUE ( Table[column] ), VALUES ( Table[column] ) )
Zubair_Muhammad
Community Champion
8 years agoHi IoanCosmin
A very good article on SELECTEDVALUE function by the champ @Marco Russo
https://www.sqlbi.com/articles/using-the-selectedvalue-function-in-dax/
- IoanCosmin8 years ago
Helper III