Forum Discussion
swicth with Slicer Selection
- 7 years ago
Hi Anonymous ,
Sorry but I'm not understanding your phrase.
In the example I send you I only place the 3 measures for comparision., if you take out the other two measure you only bet the red line that get's one or other calculation.
check PBIX file attach if this is the expected result.
Regards,
MFelix
Hi Anonymous ,
As refered your situation is refering to context. When you have two measure that you want to place in the same chart they need to be linked in any manner, and the axis of the visual needs to be inline with both measures.
On your case you are making the calculation based on the PRIMARYOUTCOMEYEARS however on both measures you use the column from each table so since you don't have any common field between them when you place it on a chart using one of the columns (in your case the STEMBRANDYEARS the othe measure gives you a straight line since the context isn't found.
What I did was to create a relationship (inactive) between the PRIMARYOUTCOMEYEARS of both tables then made the following changes:
MYKMYears v2 =
1-(CALCULATE(
PRODUCT(
'KM Years'[1-e_i/d_i]);
FILTER(ALLSELECTED(
'KM Years'[PRIMARYTOOUTCOMEYEARS]); ISONORAFTER('KM Years'[PRIMARYTOOUTCOMEYEARS];MAX('KM Years'[PRIMARYTOOUTCOMEYEARS]);DESC))))
KPYears v2 =
1
- (
CALCULATE (
PRODUCT ( 'STEMBRANDYEARS'[1-e_i/d_i] );
FILTER (
ALLSELECTED ( 'KM Years'[PRIMARYTOOUTCOMEYEARS] );
ISONORAFTER (
'KM Years'[PRIMARYTOOUTCOMEYEARS]; MAX ( 'KM Years'[PRIMARYTOOUTCOMEYEARS] ); DESC
)
);
USERELATIONSHIP ( 'KM Years'[PRIMARYTOOUTCOMEYEARS]; STEMBRANDYEARS[PRIMARYTOOUTCOMEYEARS] )
)
)
All Measure = IF (
DISTINCTCOUNT ( STEMBRANDYEARS[STEMBRAND] )
= CALCULATE ( DISTINCTCOUNT ( STEMBRANDYEARS[STEMBRAND] ); ALL ( STEMBRANDYEARS[STEMBRAND] ) );
[MYKMYears v2];
[KPYears v2]
)
Although I'm getting the correct result between the visuals there are two errors that I keep getting on the KPYears measure:
- The graph does not align the Y-axis below 100%
- And you have values that have blank values or a single point in prymaryoutcome the values are going to the top or to the bottom of the chart.
Believe that this issues are because of the way your data is structured, and the filters used on the that are not matching the context of the calculations.
Can you explain why you have the tables setup as they are?
Check PBI file attach
Regards,
MFelix