Forum Discussion
Match Different columns
- 1 year ago
Hi romovaro ,
I was planning to use lookupvalue to retrieve the headcount number from the SlippageReport table to the CapacityFile, using the 'Country' field as the identifier key. However, the duplicate 'Country' entries in the SlippageReport table are preventing me from doing that. Should there be duplicates in this context? Is this duplication due to the fact that there are multiple legal entities in Germany?
Due to this duplication, I took a different approach and brought the standard implied duration from the CapacityFile to the SlippageReport table by writing the following DAX formula.
StandardImplDuration = SWITCH( TRUE(), SlippageReport[headcount] <= 5, LOOKUPVALUE( CapacityFile[Existing 1-5], CapacityFile[Country], SlippageReport[Country] ), SlippageReport[headcount] <= 30, LOOKUPVALUE( CapacityFile[Existing 6-30], CapacityFile[Country], SlippageReport[Country] ), SlippageReport[headcount] <= 100, LOOKUPVALUE( CapacityFile[Existing 31-100], CapacityFile[Country], SlippageReport[Country] ), SlippageReport[headcount] <= 200, LOOKUPVALUE( CapacityFile[Existing 101-200], CapacityFile[Country], SlippageReport[Country] ), SlippageReport[headcount] <= 500, LOOKUPVALUE( CapacityFile[Existing 201-500], CapacityFile[Country], SlippageReport[Country] ), SlippageReport[headcount] <= 1000, LOOKUPVALUE( CapacityFile[Existing 501-1000], CapacityFile[Country], SlippageReport[Country] ), BLANK() -- Returns BLANK if none of the conditions are met )Since Cyprus is not in the CapacityFile table, the row output for Cyprus remains blank instead of showing 2, but the other outputs are in line with your expectations.
I have attached an example pbix file for your reference.
Best regards,
Hi romovaro - hope you already have a relationship between the Region and Country columns from both tables.
You will use DAX to mimic your Excel formula in Power BI. create a measure as below:
Months_to_Subtract =
VAR RegionVal = 'SlippageReport'[Work Region]
VAR CountryVal = 'SlippageReport'[Country]
VAR Headcount = 'SlippageReport'[headcount]
RETURN
CALCULATE(
SWITCH(
TRUE(),
Headcount <= 5, LOOKUPVALUE('CapacityFile'[Startup 1-5], 'CapacityFile'[Region], RegionVal, 'CapacityFile'[Country], CountryVal),
Headcount <= 30, LOOKUPVALUE('CapacityFile'[Existing 1-5], 'CapacityFile'[Region], RegionVal, 'CapacityFile'[Country], CountryVal),
Headcount <= 100, LOOKUPVALUE('CapacityFile'[Existing 6-30], 'CapacityFile'[Region], RegionVal, 'CapacityFile'[Country], CountryVal),
Headcount <= 200, LOOKUPVALUE('CapacityFile'[Existing 31-100], 'CapacityFile'[Region], RegionVal, 'CapacityFile'[Country], CountryVal),
Headcount <= 500, LOOKUPVALUE('CapacityFile'[Existing 101-200], 'CapacityFile'[Region], RegionVal, 'CapacityFile'[Country], CountryVal),
Headcount <= 1000, LOOKUPVALUE('CapacityFile'[Existing 201-500], 'CapacityFile'[Region], RegionVal, 'CapacityFile'[Country], CountryVal),
Headcount > 1000, LOOKUPVALUE('CapacityFile'[Existing 501-1000], 'CapacityFile'[Region], RegionVal, 'CapacityFile'[Country], CountryVal),
BLANK()
)
)
Now, create another calculated column in the SlippageReport that adjusts the Go Live Date based on the slippage months retrieved in the previous step.
Adjusted_Start_Date =
'SlippageReport'[Actual/Schedule Go Live date] -
( [Months_to_Subtract] * 30 ) -- Assuming an average of 30 days per month
hope this helps in your calculation to find the capacity.