Forum Discussion
Shawnee
5 years agoFrequent Visitor
Alias values using selection from same table
Hi All, I have been looking for a solution to this problem for quite some time now and have had no luck to date. Basically what I want to achieve is the following: When the slicer value i...
- 5 years ago
Hello @Shawnee ,
Create a discounted table with fruits and aliases:
SELECTED_AXIS = UNION ( ADDCOLUMNS ( DISTINCT ( Alias[Fruit] ); "Type"; "Fruit" ); ADDCOLUMNS ( DISTINCT ( Alias[Alias] ); "Type"; "ALIAS" ) )Add the following measure:
Total_Axis = IF ( HASONEVALUE ( SELECTED_AXIS[Fruit] ); SWITCH ( TRUE (); SELECTEDVALUE ( SELECTED_AXIS[Fruit] ) IN VALUES ( Alias[Fruit] ) && SELECTEDVALUE ( SELECTED_AXIS[Type] ) = "Fruit"; CALCULATE ( SUM ( 'Values'[Value] ); FILTER ( ALL ( Alias[Fruit] ); Alias[Fruit] = SELECTEDVALUE ( SELECTED_AXIS[Fruit] ) ) ); NOT ( SELECTEDVALUE ( SELECTED_AXIS[Fruit] ) IN VALUES ( Alias[Alias] ) ) && SELECTEDVALUE ( SELECTED_AXIS[Type] ) = "Alias"; CALCULATE ( SUM ( 'Values'[Value] ); FILTER ( ALL ( Alias[Alias]; Alias[Fruit] ); Alias[Alias] = SELECTEDVALUE ( SELECTED_AXIS[Fruit] ) ) ); BLANK () ); CALCULATE ( SUM ( 'Values'[Value] ); ALL ( 'Alias'[Fruit] ) ) )Now create the table and chart using column SELECTED_AXIS and Total for values, note that if you use an array the total calculation may need some adjustments:
Check the connection of the PBIX file.
MFelix
5 years agoSuper User
Hello @Shawnee ,
Create a discounted table with fruits and aliases:
SELECTED_AXIS =
UNION (
ADDCOLUMNS ( DISTINCT ( Alias[Fruit] ); "Type"; "Fruit" );
ADDCOLUMNS ( DISTINCT ( Alias[Alias] ); "Type"; "ALIAS" )
)
Add the following measure:
Total_Axis =
IF (
HASONEVALUE ( SELECTED_AXIS[Fruit] );
SWITCH (
TRUE ();
SELECTEDVALUE ( SELECTED_AXIS[Fruit] ) IN VALUES ( Alias[Fruit] )
&& SELECTEDVALUE ( SELECTED_AXIS[Type] ) = "Fruit";
CALCULATE (
SUM ( 'Values'[Value] );
FILTER (
ALL ( Alias[Fruit] );
Alias[Fruit] = SELECTEDVALUE ( SELECTED_AXIS[Fruit] )
)
);
NOT ( SELECTEDVALUE ( SELECTED_AXIS[Fruit] ) IN VALUES ( Alias[Alias] ) )
&& SELECTEDVALUE ( SELECTED_AXIS[Type] ) = "Alias";
CALCULATE (
SUM ( 'Values'[Value] );
FILTER (
ALL ( Alias[Alias]; Alias[Fruit] );
Alias[Alias] = SELECTEDVALUE ( SELECTED_AXIS[Fruit] )
)
);
BLANK ()
);
CALCULATE ( SUM ( 'Values'[Value] ); ALL ( 'Alias'[Fruit] ) )
)
Now create the table and chart using column SELECTED_AXIS and Total for values, note that if you use an array the total calculation may need some adjustments:
Check the connection of the PBIX file.
Shawnee
5 years agoFrequent Visitor
Thank you! Thye solution worked 🙂