The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
hello,
(from france)
I want to identify in a new column (powerpivot with DAX) the values that exist in column A and in column B.
ex
col A col B newCol
1 null 1
2 1 1
3 null null
4 5 5
5 null 5
Thank you for your help
Philippe
Solved! Go to Solution.
I think PowerPivot allows CONTAINS.
I'm not completely sure I understand your logic but try this:
newCol =
IF (
ISBLANK ( 'Table'[ColB] ),
IF (
CONTAINS ( 'Table', 'Table'[ColB], 'Table'[ColA] ),
'Table'[ColA]
),
'Table'[ColB]
)
@PhilippeMuniesa Try:
newCol =
VAR __B = SELECTCOLUMNS(ALL('Table'),"__C",[B])
VAR __A = SELECTCOLUMNS(ALL('Table'),"__C",[A])
VAR __AinB = IF([col A] IN __B,[col A],BLANK())
VAR __BinA = IF([col B] IN __A,[col B],BLANK())
VAR __Return = MAXX(FILTER(UNION(__AinB, __BinA),[__C] <> BLANK()),[__C])
RETURN
__Return
I had trouble following what this is trying to do, but it did inspire this solution:
newCol =
VAR _ColB = VALUES ( 'Table'[ColB] )
VAR _CurrRow = { 'Table'[ColA], 'Table'[ColB] }
RETURN
MAXX ( INTERSECT ( _ColB, _CurrRow ), 'Table'[ColB] )
it seems that the IN operator is not operational in Powerpivot would there be another solution? thank you
philippe
I think PowerPivot allows CONTAINS.
I'm not completely sure I understand your logic but try this:
newCol =
IF (
ISBLANK ( 'Table'[ColB] ),
IF (
CONTAINS ( 'Table', 'Table'[ColB], 'Table'[ColA] ),
'Table'[ColA]
),
'Table'[ColB]
)
thank you,
It' s ok,
in the meantime, I tried a solution similar to yours,
"for english must replace ; by ,"
which I also post with an excel file containing the table, and the dax part in powerpivot for members who are interested.
a big thank you to you
https://www.dropbox.com/t/7P1YZjrKZJ3TSs3q
Philippe
thank you, but problème with french traduction , as ; and error with __
Thank you
philippe
User | Count |
---|---|
10 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
20 | |
15 | |
14 | |
10 | |
7 |