Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Analitika
Post Prodigy
Post Prodigy

Gone measure results after Matrix value selected

 

Data model

Data modelData model

 

SalesAmountWithTotal = VAR _CurrentAxis = SELECTEDVALUE('DimChannelTotal'[ChannelName]) RETURN IF(_CurrentAxis = "Total"; IF(SELECTEDVALUE(YesNo[Values];1) = "Yes"; SUM(FactSales[SalesAmount]); BLANK() ); CALCULATE( SUM(FactSales[SalesAmount]); DimChannel[ChannelName] = _CurrentAxis ) )

 

image-3.png

 

And Matrix

DimChannel[ChannelName] | DimChannel[ChannelLabel] | FactSales[DataKey]

 

Problem is that ChannelName working good only if i press in matrix on DimChannel[ChannelName], if in matrix i press on column value only Total left and i cant see ChannelName anymore. So how to show always ChannelName not matter which column value selected?

 

 

and why if i put in separate measure _CurrentAxis = SELECTEDVALUE('DimChannelTotal'[ChannelName])

it always showing empty values but working in SalesAmountWithTotal measure?

1 ACCEPTED SOLUTION

Hi @Analitika ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. I created a column chart as a custom legend... And for SELECTEDVALUE( ) return the value which the field filtered, it will return no data if there is no data selected...

yingyinr_0-1627280854544.png

You can also refer the below video to get it.

Want a custom LEGEND for your Power BI visual? WATCH THIS!

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @Analitika ,

As checked your post description, the line chart using the field DimChannel[ChannelName] not the field 'DimChannelTotal'[ChannelName], so please update the formula of your measure [SalesAmountWithTotal] as below and check whether you can get the correct result:

SalesAmountWithTotal =
VAR _CurrentAxis = DimChannel[ChannelName]
RETURN
    IF (
        _CurrentAxis = "Total",
        IF (
            SELECTEDVALUE ( YesNo[Values], 1 ) = "Yes",
            SUM ( FactSales[SalesAmount] ),
            BLANK ()
        ),
        CALCULATE (
            SUM ( FactSales[SalesAmount] ),
            DimChannel[ChannelName] = _CurrentAxis
        )
    )

yingyinr_0-1627269563194.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Nope. this is not working, as DimChannel[ChannelName]  never = "Total"

As Total is custom created field, so if i do like your example i loosing Total line in chart

 

DimChannelTotal =

FILTER (
DISTINCT (
UNION (
DISTINCT ( DimChannel[ChannelName] ),
ROW ( "Selected", "Selected" ),
ROW ( "Total", "Total" )
)
),
NOT ISBLANK ( [ChannelName] )
)

Hi @Analitika ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. I created a column chart as a custom legend... And for SELECTEDVALUE( ) return the value which the field filtered, it will return no data if there is no data selected...

yingyinr_0-1627280854544.png

You can also refer the below video to get it.

Want a custom LEGEND for your Power BI visual? WATCH THIS!

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.