Forum Discussion
test2sa
2 years agoHelper I
loop through table to replace certain values? for each loop? not sure how to approach issue
Not sure how to approach this in PowerBI. If this were a normal imperative programming language, I would just write a for-each loop. I have an excel sheet of data in a Power BI report. Quote Num...
- 2 years ago
test2sa I assume you are trying to add a calculated column to the data model? In that case you can use this:
WinnerName = VAR Winner = CALCULATE ( SELECTEDVALUE ( 'Table'[Shop] ), 'Table'[Winner] = "Y", ALLEXCEPT ( 'Table', 'Table'[Quote Number] ) ) RETURN IF ( 'Table'[External Shop] = "FEF", "FEF", Winner )
AntrikshSharma
2 years agoCommunity Champion
test2sa I assume you are trying to add a calculated column to the data model? In that case you can use this:
WinnerName =
VAR Winner =
CALCULATE (
SELECTEDVALUE ( 'Table'[Shop] ),
'Table'[Winner] = "Y",
ALLEXCEPT ( 'Table', 'Table'[Quote Number] )
)
RETURN
IF (
'Table'[External Shop] = "FEF",
"FEF",
Winner
)
- test2sa2 years agoHelper I
Thank you!! I've almost got it working. I'm having trouble with that IF statement at the very end.
IF (
NOT(ISBLANK('Table'[External Shop])),
'Table'[External Shop],
Winner
)
I've tried writing it a bunch of different ways and it wants to return only Winner or only External Shop. It won't return the correct one for each quote.- AntrikshSharma2 years agoCommunity Champion
test2sa you can do IF ( 'Table'[External Shop] <> "", 'Table'[External Shop] , Winner )
- test2sa2 years agoHelper I
Thank you!! That worked perfectly!