Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Background:
A number of people (ID column) rode different modes of transport (Mode column) that were built by different manufacturers (Manufacturer column) and when asked if they liked it they reported either 'No', 'Yes', or 'Partially' (Like column).
ID | Manufacturer | Mode | Like |
1 | Space | Shuttle | Yes |
1 | Space | Pod | No |
1 | Space | Bike | No |
1 | Venom | Shuttle | Partially |
1 | Venom | Pod | No |
1 | Venom | Bike | Yes |
2 | Space | Shuttle | Yes |
2 | Space | Pod | Yes |
2 | Space | Bike | No |
2 | Venom | Shuttle | No |
2 | Venom | Pod | No |
2 | Venom | Bike | No |
3 | Space | Shuttle | No |
3 | Space | Pod | Yes |
3 | Space | Bike | Partially |
3 | Venom | Shuttle | Partially |
3 | Venom | Pod | No |
3 | Venom | Bike | No |
Result I want:
For each mode (Mode), how many people liked the experience (Like = Yes) of any manufacturer (Manufacturer); if they didn't like the experience of any manufacturer, then how many people partially liked the experience of any manufacturer; and how many people didn't like the experience by all manufacturers.
Put another way, I think I want to create the column New (see below) that follows the rule:
If Like= "Yes" for any of the rows with the same ID then New = "Yes", else
If Like = "Partial" for any of the rows with the same ID then New = "Partial", else
If Like = "No" for any of the rows with the same ID then the New = "No".
ID | Manufacturer | Mode | Like | New |
1 | Space | Shuttle | Yes | Yes |
1 | Space | Pod | No | No |
1 | Space | Bike | No | Yes |
1 | Venom | Shuttle | Partially | Yes |
1 | Venom | Pod | No | No |
1 | Venom | Bike | Yes | Yes |
2 | Space | Shuttle | Yes | Yes |
2 | Space | Pod | Yes | Yes |
2 | Space | Bike | No | No |
2 | Venom | Shuttle | No | Yes |
2 | Venom | Pod | No | Yes |
2 | Venom | Bike | No | No |
3 | Space | Shuttle | No | Partially |
3 | Space | Pod | Yes | Yes |
3 | Space | Bike | Partially | Partially |
3 | Venom | Shuttle | Partially | Partially |
3 | Venom | Pod | No | Yes |
3 | Venom | Bike | No | Partially |
So essentially, a "Yes" overrides "Partial" and "No"; "Partial" overrides "No"; everything else is "No".
Then after the New column is created, I'd like to count the distinct number of IDs per Mode and Like.
I was doing this by adding a column using (thanks @jdbuchanan71) :
New =
VAR _Yes = CALCULATE(COUNTROWS(VALUES('Table'[ID])),'Table'[Like]="Yes",ALLEXCEPT('Table','Table'[ID]))
VAR _Partial = CALCULATE(COUNTROWS(VALUES('Table'[ID])),'Table'[Like]="Partial",ALLEXCEPT('Table','Table'[ID]))
RETURN
SWITCH(
TRUE(),
_Yes > 0, "Yes",
_Partial > 0, "Partial",
"No"
)
The visual (below) correctly demonstrates what I want, when all Projects are selected.
However, now I'd like the above to also respond to a slicer that filters by Manufacturer. For example, if I filter by Manufacturer = Venom, then I want the result of New for the Shuttle row to no longer be 'Yes', but instead 'Partially'.
ID | Manufacturer | Mode | Like | New |
1 | Space | Shuttle | Yes | Yes |
1 | Space | Pod | No | No |
1 | Space | Bike | No | Yes |
1 | Venom | Shuttle | Partially | Yes (I want this to be 'Partially' when filtered to Venom) |
1 | Venom | Pod | No | No |
1 | Venom | Bike | Yes | Yes |
Or, if I filter by Manufacturer = Space, then I want the result of New for the Bike column to no longer be 'Yes', but instead 'No'.
ID | Manufacturer | Mode | Like | New |
1 | Space | Shuttle | Yes | Yes |
1 | Space | Pod | No | No |
1 | Space | Bike | No | Yes (I want this to be 'No' when filtered to Space) |
1 | Venom | Shuttle | Partially | Yes |
1 | Venom | Pod | No | No |
1 | Venom | Bike | Yes | Yes |
Note, I will eventually add more "Manufacturers".
@freemainia Try implementing it as a measure.
Cheers @Greg_Deckler.
I attempt to create it as a measure, however, this doesn't allow me to drag it into the visualisation (bar chart).
@freemainia If you are trying to use it as an x-axis, you will need to use a measure along with a disconnected table. In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...