Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
I try to find my answer online, but after a day without success I hope that maybe one of you can help me with my issue.
What I try to do is: if a field has a value that can be found in that other table, it
So let's say this is the main data set I have right now:
MainTable
Columns:
Supermarket, AppleSize, BananaSize
Supermarket1, Big, Big
Supermarket2, Big, XXL
Supermarket3, Small, XL
Supermarket4, Little, XXL
And in another table we have all values the supermarkets can choose:
FruitTable
Columns:
Category,Type,Size
Fruit, Apple, Big
Fruit, Apple, Small
Fruit, Apple, Normal
Fruit, Banana, Big
Fruit, Banana, XXL
You see now that in my main data set,:
Supermarket4 gave the wrong value for the size of the apples they sell (Little, while only Big, Small or Normal are allowed)
Supermarket3 gave the wrong value for the size of the bananas they sell (XL, while only Big or XXL are allowed)
What I want is to measure how many % is correctly filled in, and with bare eyes you can see that for the applesize 75% is correctly filled in and the same goes for bananas. However, how to calculate this?
What I want to do is add a new calculated colum with an IF statement in it: IF the value 'Big' is found in the 'Fruittable' for type 'Apple', then say "Yes", else "No". Then I can count the y/n's to get the % out of it.
All the help, greatly appreciated!
Kind regards,
Igor
Solved! Go to Solution.
Hi Igor,
Add these two calculated columns please. Then calculating the % would be easy.
AppleCheck = VAR appleSizes = CALCULATETABLE ( VALUES ( FruitTable[Size] ), 'FruitTable'[Type] = "Apple" ) RETURN IF ( [AppleSize] IN appleSizes, "Yes", "No" )
BananaCheck = VAR BananaSizes = CALCULATETABLE ( VALUES ( FruitTable[Size] ), 'FruitTable'[Type] = "Banana" ) RETURN IF ( [BananaSize] IN BananaSizes, "Yes", "No" )
% = DIVIDE ( CALCULATE ( COUNT ( MainTable[AppleCheck] ), MainTable[AppleCheck] = "Yes" ), COUNT ( MainTable[AppleCheck] ), 0 )
Best Regards,
Dale
Important addition:
You could say something like this (probably not entirely correct)
IF( FruitTable[Apple] = "Big" || "Small" || "Yes"; "Yes"; "No"
But it has to lookup the values which are allowed from that table, since you don't want to change all the calculated columns' IF statements, when the possible allowed values in the FruitTable are extended.
Kind regards,
Igor
Hi Igor,
Add these two calculated columns please. Then calculating the % would be easy.
AppleCheck = VAR appleSizes = CALCULATETABLE ( VALUES ( FruitTable[Size] ), 'FruitTable'[Type] = "Apple" ) RETURN IF ( [AppleSize] IN appleSizes, "Yes", "No" )
BananaCheck = VAR BananaSizes = CALCULATETABLE ( VALUES ( FruitTable[Size] ), 'FruitTable'[Type] = "Banana" ) RETURN IF ( [BananaSize] IN BananaSizes, "Yes", "No" )
% = DIVIDE ( CALCULATE ( COUNT ( MainTable[AppleCheck] ), MainTable[AppleCheck] = "Yes" ), COUNT ( MainTable[AppleCheck] ), 0 )
Best Regards,
Dale
Thanks a lot Dale!
Works like a charm.
Kind regards,
Igor
Hi,
I think this is similar as it involves an IF statement that references more than 1 table.
So, in this basic example I have 2 tables and want to say something like:
IF( Table1[ColumnA] = "XXX" && Table2[ColumnB] = "YYY", "Result A", "Result B")
In my real example both Table 1 and Table 2 have a direct relationship with a master table, so an indirect relationship with each other. I have also tried a simplified version with the same data, just these 2 tables with a many to many relationship to see if that made it any easier but it hasn't!
I am not sure if you do this another way in Power BI as I can't seem to find an easy solution anywhere?
Any help appreciated! Thanks!
User | Count |
---|---|
128 | |
108 | |
100 | |
64 | |
62 |
User | Count |
---|---|
136 | |
113 | |
102 | |
71 | |
60 |