Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
I have two tables and want to use the values in the table/column 'JCCD'[ActualCost] except when in the values in table/column 'bihj HeavyJob_CostSummary'[HJCost] are higher than in the 'JCCD'[ActualCost] table/column only when 'HeavyJob_CostSummary'[LMSEO] or 'JCCD'[LMSEO] has a value of "Labor" or "Material". This works with the following:
Hi, @efstel
Based on your information, I create sample tables:
Create a new measure and try the following DAX:
CorrectedMeasureCO =
SUMX(
'bihj HeavyJob_CostSummary',
VAR LMSEO_Value = 'bihj HeavyJob_CostSummary'[LMSEO]
VAR HJCost = 'bihj HeavyJob_CostSummary'[HJCost]
VAR ActualCost = CALCULATE(SUM('JCCD'[ActualCost]), 'JCCD'[LMSEO] = LMSEO_Value)
RETURN
IF(
LMSEO_Value IN {"Labor", "Material"} && HJCost > ActualCost,
HJCost,
ActualCost
)
)
Also create relationship:
It compares two tables of data and takes the largest one. Here is my preview:
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
That is not working correclty. Also, I can't create a relationship between the 'JCCD' table and the 'bihj HeavyJob_CostSummary' table other than a many to many. The tables come from two different data sources and have millions of lines of data. However, there is the following relationship between the tables.
JCJP is a dimension table and contains unique JobNoCostCode. 'JCCD' and 'bihj HeavyJob_CostSummary' are both fact tables.
@efstel
You need to interate over the table, this will get the sub total right:
NewMeasureCO =
SUMX(
'JCCD',
VAR LMSEO_Value = LOOKUPVALUE('bihj HeavyJob_CostSummary'[LMSEO], 'bihj HeavyJob_CostSummary'[KeyColumn], 'JCCD'[KeyColumn])
VAR HJCost = LOOKUPVALUE('bihj HeavyJob_CostSummary'[HJCost], 'bihj HeavyJob_CostSummary'[KeyColumn], 'JCCD'[KeyColumn])
VAR ActualCost = 'JCCD'[ActualCost]
RETURN
IF(
LMSEO_Value IN {"Labor", "Material"} && HJCost > ActualCost,
HJCost,
ActualCost
)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
I'm not 100% sure what "KeyColumn" to use in the two tables. I've tried what I thougth was correct, but I keep getting an "Error fetching data" message that states "A table of multiple values was supplied where a sigle value was expected."
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
13 | |
11 | |
10 | |
9 |
User | Count |
---|---|
18 | |
14 | |
14 | |
12 | |
11 |