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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
pradeepksahoo
New Member

DAX formula - How to turn count summarization to negative value in a stacked column visual

I am trying to create a stacked column in BI. However, I would like one of the category values - in this case, the count of stage value of 0-Waiting to be shown in -ve. In other words, for Jan, Mar, Apr - the values of 2, 2, 1 should be -2, -2, -1.

 

Appreciate any help with DAX query or any other approach of how I can achieve in Power BI. Thanks in advance

 

An example in excel with data is shown below

ItemMonthStateStage
1Jan-21In Process0-Waiting
2Jan-21In Process1-Started
3Jan-21Completed2-Final
6Jan-21In Process1-Started
7Jan-21In Process0-Waiting
8Jan-21Completed1-Started
1Feb-21In Process1-Started
2Feb-21In Process1-Started
1Mar-21In Process1-Started
4Mar-21In Process0-Waiting
5Mar-21In Process0-Waiting
1Apr-21In Process1-Started
2Apr-21Completed2-Final
4Apr-21In Process0-Waiting

 

pradeepksahoo_0-1629628594142.png

 

2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

Here is a measure that shows one way to do it.  Just change Items to your actual table name.

 

mahoneypat_0-1629631289605.png

 

 

ItemCount =
VAR inprogress =
    CALCULATE (
        COUNT ( Items[Item] ),
        KEEPFILTERS ( Items[Stage] IN { "1-Started""2-Final" } )
    )
VAR waiting =
    CALCULATE ( COUNT ( Items[Item] )KEEPFILTERS ( Items[Stage] = "0-Waiting" ) )
RETURN
    0 + inprogress - waiting

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Perhaps you already did this, but you can add this as another clause in the CALCULATE for that variable.

 

Items[State] <> "Completed"
 
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Here is a measure that shows one way to do it.  Just change Items to your actual table name.

 

mahoneypat_0-1629631289605.png

 

 

ItemCount =
VAR inprogress =
    CALCULATE (
        COUNT ( Items[Item] ),
        KEEPFILTERS ( Items[Stage] IN { "1-Started""2-Final" } )
    )
VAR waiting =
    CALCULATE ( COUNT ( Items[Item] )KEEPFILTERS ( Items[Stage] = "0-Waiting" ) )
RETURN
    0 + inprogress - waiting

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat ,

Many thanks for your prompt help. It seems to almost work. Except that I wanted another condition to be in the filter i.e. the state value of "In Process". The -ve count should not be applied for records which have state as "Completed"

 

Thanks again for your help

 

Pradeep

Perhaps you already did this, but you can add this as another clause in the CALCULATE for that variable.

 

Items[State] <> "Completed"
 
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.