Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi All,
Hoping you you may be able to assist with my questions/challenge.
I have the below table and am wanting to achieve the output of the Column named "Remaining Sites"
Current :
Hoping to create a Column named "Remaining Sites" :
The unique combination of values are Ship, Ship Type, Ship Style and Sites.
So for each combination of Ship, Ship Type, Ship Style and Sites there are areas which get enetered in.
I am looking to have a column called "Remaining Sites" which looks up the value of 'Sites' and removes the 'Areas'.
Using the first 2 rows as an example, the Sites are: BB,EE,FF and I am needing to take away the areas for that Ship, Ship Type, Ship Style which are BB and EE. This would leave the column with FF.
I have tried to use a Matrix and then use LOOKUP VALUE which any luck. Have also tried to use the FIND and SEARCH functions but haven't got anywhere as of yet.
Apprecaite any help or guidance.
Solved! Go to Solution.
Hi @powerbiuser1000 ,
Dax's text functions are not very good at solving such problems.
Remaining Sites =
VAR _TEXT =
SUBSTITUTE (
[Sites],
CONCATENATEX (
FILTER ( ALL ( 'Table' ), 'Table'[Ship] = EARLIER ( 'Table'[Ship] ) ),
'Table'[Area],
","
),
""
)
VAR _RESULT =
SWITCH(
TRUE(),
LEFT(_TEXT,1)=",",MID(_TEXT,2,LEN(_TEXT)-1),
RIGHT(_TEXT,1)=",",MID(_TEXT,2,LEN(_TEXT)-1)
)
RETURN
_RESULT
This may only be appropriate for sample data. I'm guessing that [Sites] and [Areas] are probably calculated columns, so please consider refactoring them in the PowerQuery Editor to make the question much simpler.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi @powerbiuser1000 ,
Dax's text functions are not very good at solving such problems.
Remaining Sites =
VAR _TEXT =
SUBSTITUTE (
[Sites],
CONCATENATEX (
FILTER ( ALL ( 'Table' ), 'Table'[Ship] = EARLIER ( 'Table'[Ship] ) ),
'Table'[Area],
","
),
""
)
VAR _RESULT =
SWITCH(
TRUE(),
LEFT(_TEXT,1)=",",MID(_TEXT,2,LEN(_TEXT)-1),
RIGHT(_TEXT,1)=",",MID(_TEXT,2,LEN(_TEXT)-1)
)
RETURN
_RESULT
This may only be appropriate for sample data. I'm guessing that [Sites] and [Areas] are probably calculated columns, so please consider refactoring them in the PowerQuery Editor to make the question much simpler.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Thank you, this is exactly what I am after! Cheers
Use EXCEPT for that, or NOT IN { }.
Hi Ibendlin, thank you for that. However for Ship 1, it needs to lookup the 'area' for both the 1st and 2nd row and then use NOT IN { }.
For example, the 1st row needs to consider the 2nd row. And the 2nd row needs to consider the first. So need to add BB and EE and then subtract from 'Sites':
So BB, EE NOT IN {'Sites'), so the result can be FF as shown in the second table above.
Yes, I assumed you know how to handle filter context.
Hi Ibendlin, Thank you for your reply. I am not exactly sure how to do that. Are you able to clarify? thank you.
User | Count |
---|---|
20 | |
14 | |
11 | |
8 | |
6 |
User | Count |
---|---|
23 | |
23 | |
20 | |
15 | |
10 |