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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
lokosrio
Helper II
Helper II

Divide sum by total for items where sum is greater than zero

Hi,

 

I have a data like in the table below:

lokosrio_0-1597846395852.png

 

...




On my chart I want to get data like in the table below:

lokosrio_1-1597846411703.png

 

 

1. I want to show only values where the sum > 0
2. Divide the sum/total to present the result as a contribution


 

Right now I have only DAX which helps me get the elements where the value is bigger than zero:

CALCULATE(SUM('Table'[Measure]),
FILTER(ALL('Table'[Measure]),
SUM('Table'[Measure]) > 0))

 

Could you help me with this, please?

Thank you in advance!

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @lokosrio ,

 

Refer:

sum if>0 =
VAR sum_by_dim2 =
    CALCULATE ( SUM ( 'Table'[Measure] ), ALLEXCEPT ( 'Table', 'Table'[Dim2] ) )
RETURN
    IF ( sum_by_dim2 > 0, sum_by_dim2 )
result =
VAR total =
    CALCULATE (
        SUM ( 'Table'[Measure] ),
        FILTER ( ALL ( 'Table' ), [sum if>0] > 0 )
    )
RETURN
    DIVIDE ( [sum if>0], total )

V-lianl-msft_0-1597911536494.png

 

 

Best Regards,
Liang
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-lianl-msft
Community Support
Community Support

Hi @lokosrio ,

 

Refer:

sum if>0 =
VAR sum_by_dim2 =
    CALCULATE ( SUM ( 'Table'[Measure] ), ALLEXCEPT ( 'Table', 'Table'[Dim2] ) )
RETURN
    IF ( sum_by_dim2 > 0, sum_by_dim2 )
result =
VAR total =
    CALCULATE (
        SUM ( 'Table'[Measure] ),
        FILTER ( ALL ( 'Table' ), [sum if>0] > 0 )
    )
RETURN
    DIVIDE ( [sum if>0], total )

V-lianl-msft_0-1597911536494.png

 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@lokosrio , you have try like

divide(sum(Table[measure]),calculate(sum(Table[measure]), all(Table[dim])))

or

divide(sum(Table[measure]),calculate(sum(Table[measure]), allselected(Table[dim])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Unfortunately it is not working, because in the calculation I need to filter only values where the sum is greater than 0. In your calculation I am taking all values, which is not the case here

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.