Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi all I need your help !
I have a table like below, I need to comparaire value from category A with values from category A.1 and A.2
I need a new column with flag "same" or "different".
How can I do this ?
Category | Value |
A | ABC |
A.1 | A |
A.2 | ABC |
A.2 | DEF |
A.3 | ABC |
A.4 | DEF |
Solved! Go to Solution.
Load your data into the power bi desktop
Now create the flowing calculated column
Status =
VAR val = data[Value]
VAR result =
CALCULATE ( COUNTROWS ( data ), ALL ( data ), data[Value] = val )
RETURN
IF ( result == 1, "different", "Same" )
You will get your expected results.
Load your data into the power bi desktop
Now create the flowing calculated column
Status =
VAR val = data[Value]
VAR result =
CALCULATE ( COUNTROWS ( data ), ALL ( data ), data[Value] = val )
RETURN
IF ( result == 1, "different", "Same" )
You will get your expected results.
@Royel ,Thank you but I need to add a condition on Category because I can have a completly different categories like B etc. How can I do that ? Thank you !
Why do we not use EARLIER function ?
need to comparaire result of A category to all sub categories. But I can have more than one primary category
@freginier my friend, you are making me take gueses here..
Do you want to do a quick zoom to show me?
it's very simple 😉
See the table below I need to find when :
- Category A value (ABC) it's repeat on subcategories (A.2 and A.3) then flag "SAME"
- Category B value (DE) it's repeat on subcategories (B.2) then falg "SAME"
Category | Value |
A | ABC |
A.1 | A |
A.2 | ABC |
A.2 | DEF |
A.3 | ABC |
A.4 | DEF |
B | DE |
B.1 | EF |
B.2 | DE |
more clear ?
@freginier nope 🙂 becaue I guess your data doesn't look like A and B so I need to actually see what's going on 🙂
If you want to do a zoom I'm available to help
I can't show you more than A and B because it's confidential data !
The @Royel answer work just need to know how to add a condition on category because I have more than one primary category
@freginier ok ok haha , let's try this (won't work, but it will derive from what you see here. Just want to clarify my point, look at my next reply):
Status =
VAR val = data[Value]
VAR cat = data[Cateogry]
VAR result =
CALCULATE ( COUNTROWS ( data ), ALL ( data ), data[Value] = val, data[Category] = cat )
RETURN
IF ( result == 1, "different", "Same" )
Why don't use EARLIER function ?
@freginier EARLIER fucntion was used greatly and was very important until the introduction of Variables. That new capability made the EARLIER function not needed becasue the VARs are more clear to read. We can do it also with EARLIER but it's best to start working with VARs cause they have a lot of benefits
@freginier that wouldn't work exactly for the reason I said. I need to know how to filter by the same cateogty rows and for that I need to know what is the textual logic. If they all start with the same letter and that is different between the categories then ok, we can do that, but that is exactly why I told you that I need to see the data or that you need to give more info.
@freginier hey, can you just clarify when do you want to get "Same" and when "Different"? on your sample data.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.