Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Ive been trying to do this logic where if the age match any of the value in the first column it will result the respective value in the second up to seventh column.
Ive been trying this code
Solved! Go to Solution.
Hi @RaineJ
To be honest, I'm not sure if I correctly understand the requirement. However, this is a rather complex solution for you to check from your end. Please refer to attached sample file.
Status =
VAR CurrentTable =
SELECTCOLUMNS (
FILTER ( 'Table', 'Table'[AIM] = EARLIER ( 'Table'[AGE] ) ),
"SUW", [SUW_G], "UW", [UW+_G], "UW-", [UW-_G], "N", [N+_G], "N-", [N-_G], "OGW", [OW_G], "AGE", [AGE]
)
VAR String1 = TOCSV ( CurrentTable, 1 )
VAR Items1 = SUBSTITUTE ( String1, UNICHAR ( 10 ), "|" )
VAR String2 = PATHITEM ( Items1, 1 )
VAR Items2 = SUBSTITUTE ( String2, ",", "|" )
VAR Length = COALESCE ( PATHLENGTH ( Items2 ), 1 )
VAR String3 = PATHITEM ( Items1, 2 )
VAR Items3 = SUBSTITUTE ( String3, ",", "|" )
VAR T1 = GENERATESERIES ( 1, Length, 1 )
VAR T2 = ADDCOLUMNS ( T1, "@Name", PATHITEM ( Items2, [Value] ), "@Value", VALUE ( PATHITEM ( Items3, [Value] ) ) )
VAR T3 = FILTER ( T2, [@Value] = 'Table'[WEIGHT] )
VAR ColumnName = SUBSTITUTE ( MAXX ( T3, [@Name] ), "-", "" )
VAR Result = SUBSTITUTE ( SUBSTITUTE ( ColumnName, "[", "" ), "]", "" )
RETURN
Result
Hi @RaineJ
To be honest, I'm not sure if I correctly understand the requirement. However, this is a rather complex solution for you to check from your end. Please refer to attached sample file.
Status =
VAR CurrentTable =
SELECTCOLUMNS (
FILTER ( 'Table', 'Table'[AIM] = EARLIER ( 'Table'[AGE] ) ),
"SUW", [SUW_G], "UW", [UW+_G], "UW-", [UW-_G], "N", [N+_G], "N-", [N-_G], "OGW", [OW_G], "AGE", [AGE]
)
VAR String1 = TOCSV ( CurrentTable, 1 )
VAR Items1 = SUBSTITUTE ( String1, UNICHAR ( 10 ), "|" )
VAR String2 = PATHITEM ( Items1, 1 )
VAR Items2 = SUBSTITUTE ( String2, ",", "|" )
VAR Length = COALESCE ( PATHLENGTH ( Items2 ), 1 )
VAR String3 = PATHITEM ( Items1, 2 )
VAR Items3 = SUBSTITUTE ( String3, ",", "|" )
VAR T1 = GENERATESERIES ( 1, Length, 1 )
VAR T2 = ADDCOLUMNS ( T1, "@Name", PATHITEM ( Items2, [Value] ), "@Value", VALUE ( PATHITEM ( Items3, [Value] ) ) )
VAR T3 = FILTER ( T2, [@Value] = 'Table'[WEIGHT] )
VAR ColumnName = SUBSTITUTE ( MAXX ( T3, [@Name] ), "-", "" )
VAR Result = SUBSTITUTE ( SUBSTITUTE ( ColumnName, "[", "" ), "]", "" )
RETURN
Result
Thank you sir it already works for me. i just got confused with my data.
thank you sir but it dont work for me when i input different age.
My bad sir. As I tried your code I only got the correct prediction in 0 but when I input different age like 1,2 55,56, and 60. It didnt show any prediction.
As you can see in my sample file I have used 3 different values for the AGE column and it worked just fine. Therefore I believe I don't fully understand the logic. Can we connect now via teams or zoom perhaps to clarify further?
Thank you, but i still have the same problem.
it only show result if the cell in the same row matched
im really thankful sir. but it is still the same in my case.
the first row only got the right prediction while the rest, output the "OW".
im a beginner with this so im wondering if its possible.
Status =
VAR _tbl =
FILTER ( 'Measure', 'Measure'[AGE] = EARLIER ( 'Measure'[AIM] ) )
RETURN
SWITCH (
TRUE (),
'Measure'[WEIGHT] <= MAXX ( _tbl, 'Measure'[SUW_G] ), "SUW",
'Measure'[WEIGHT] >= MAXX ( _tbl, 'Measure'[UW+_G] )
&& 'Measure'[WEIGHT] <= MAXX ( _tbl, 'Measure'[UW-_G] ), "UW",
'Measure'[WEIGHT] <= MAXX ( _tbl, 'Measure'[N+_G] )
&& MAXX ( _tbl, 'Measure'[WEIGHT] ) <= 'Measure'[N-_G], "N",
'Measure'[WEIGHT] >= MAXX ( _tbl, 'Measure'[OW_G] ), "OW"
)
i got a wrong filter condition
the result still the same sir.
User | Count |
---|---|
54 | |
22 | |
19 | |
16 | |
11 |
User | Count |
---|---|
82 | |
55 | |
39 | |
20 | |
12 |