Forum Discussion
Copy Values
- Anonymous1 year ago
Hi, Anonymous
According to your description, I created the following two tables:
I use the following DAX expression, which mainly uses the lookup value to obtain the code of another table, so that the number of id, code, and name can be matched:
Table 2= VAR _table = ADDCOLUMNS ( ADDCOLUMNS ( SELECTCOLUMNS ( 'Table', 'Table'[Key], 'Table'[Name], 'Table'[Code] ), "Id", LOOKUPVALUE ( 'Table 2 (2)'[Code], 'Table 2 (2)'[ID], 'Table'[Key] ) ), "Value1", [Measure1], "Value2", [Measure2], "Value3", [Measure3] ) RETURN ADDCOLUMNS ( _table, "Value1_new", VAR _id = [Id] RETURN IF ( ISBLANK ( [Value1] ), FIRSTNONBLANK ( SELECTCOLUMNS ( FILTER ( _table, [Id] = _id ), [Value1] ), [Value1] ), [Value1] ), "Value2_new", VAR _id = [Id] RETURN IF ( ISBLANK ( [Value2] ), FIRSTNONBLANK ( SELECTCOLUMNS ( FILTER ( _table, [Id] = _id ), [Value2] ), [Value2] ), [Value2] ), "Value3_new", VAR _id = [Id] RETURN IF ( ISBLANK ( [Value3] ), FIRSTNONBLANK ( SELECTCOLUMNS ( FILTER ( _table, [Id] = _id ), [Value3] ), [Value3] ), [Value3] ) )I have included the PBIX file used for this tutorial below.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can write a measure:
Value1_Fill =
IF (
ISBLANK ( MAX(YourTable[Value1]) ),
CALCULATE (
MAX(YourTable[Value1]),
FILTER (
YourTable,
YourTable[Name] = MAX(YourTable[Name]) &&
NOT(ISBLANK(YourTable[Value1]))
)
),
MAX(YourTable[Value1])
)
Similarly write for Value2 and Value3.
If this post helps, please consider Accepting it as the solution to help the other members find it more quickly and Your Kudos/Likes are much appreciated!
Regards,
Kedar Pande
www.linkedin.com/in/kedar-pande
- Anonymous1 year agoNot applicable
Kedar_Pande Thanks I get this error "The MAX function only accepts a column reference as the argument number 1."
- Kedar_Pande1 year agoSuper User
Here’s the updated solution using SELECTEDVALUE():
Value1_Fill =
IF (
ISBLANK ( SELECTEDVALUE(YourTable[Value1]) ),
CALCULATE (
MAX(YourTable[Value1]),
FILTER (
YourTable,
YourTable[Name] = SELECTEDVALUE(YourTable[Name]) &&
NOT(ISBLANK(YourTable[Value1]))
)
),
SELECTEDVALUE(YourTable[Value1])
)- Anonymous1 year agoNot applicable
@Thanks I get "Parameter not correct type" for the measure. The Measure is calculated by dividing 2 columns.