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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
bml123
Post Patron
Post Patron

Negative value not appearing in stacked bar chart, want to show negative as positive at the top

Hi,

 

I have a stacked column chart with totals and the variance.  If there is a negative value, it's not showing up in the stacked column chart as below.   I want to show the negative amount as positive at the top.  How do I achieve that?

 

bml123_0-1656671463093.png

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @bml123,

Did you mean to summary your records based on value symbol(positive/negative) and display them with positive value?

If that is the case, you can create a table with positive, and negative strings and use new table field on chart legends.

After these steps, you can write a measure fromula with a variable to aggregate value and return different results based on current category values.

formula =
VAR currType =
    SELECTEDVALUE ( NewTable[Type] ) //positive, negative 
RETURN
    SWITCH (
        currType,
        "positive",
            CALCULATE (
                SUM ( Table[Sales] ),
                FILTER ( ALLSELECTED ( Table ), [Sales] > 0 ),
                VALUES ( Table[Category] )
            ),
        "negative",
            CALCULATE (
                ABS ( SUM ( Table[Sales] ) ),
                FILTER ( ALLSELECTED ( Table ), [Sales] < 0 ),
                VALUES ( Table[Category] )
            )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @bml123,

Did you mean to summary your records based on value symbol(positive/negative) and display them with positive value?

If that is the case, you can create a table with positive, and negative strings and use new table field on chart legends.

After these steps, you can write a measure fromula with a variable to aggregate value and return different results based on current category values.

formula =
VAR currType =
    SELECTEDVALUE ( NewTable[Type] ) //positive, negative 
RETURN
    SWITCH (
        currType,
        "positive",
            CALCULATE (
                SUM ( Table[Sales] ),
                FILTER ( ALLSELECTED ( Table ), [Sales] > 0 ),
                VALUES ( Table[Category] )
            ),
        "negative",
            CALCULATE (
                ABS ( SUM ( Table[Sales] ) ),
                FILTER ( ALLSELECTED ( Table ), [Sales] < 0 ),
                VALUES ( Table[Category] )
            )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@bml123 ,

You need to create an absolute measure

 

M1  = abs([measure])



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.