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
wangjuan303
Helper III
Helper III

How to sum a measure when this measure greater than 0

Hi Team, 

I am working n a report, need show "Diff" for two date, 

in the "Diff" measure, some is greater than 0, it is the increase

some is less than 0, it is the decrease, 

wangjuan303_0-1660521346731.png

 

I need to calculatethe total "Diff” where all Industries greater than 0,  (all the increased amount for Industry)

for example , I need get 128 for total increase. 

wangjuan303_0-1660527858816.png

Here is related file link : 

https://www.dropbox.com/s/h2yj6w6ylvjdtcd/Diff.pbix?dl=0

Thank you ahead for any idea for this measure

1 ACCEPTED SOLUTION

You can use and IF condition so it returns blank for those with negative [Diff]

Total Increase ALL =
IF (
    [Diff] > 0,
    CALCULATE (
        [Diff],
        FILTER (
            ALL ( 'Fact Table'[Industry], 'Fact Table'[Scenario] ),
            VAR _diff = [Diff] RETURN _diff > 0
        )
    )
)

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @wangjuan303 ,

 

Please try this:

 

Total Increase = 
SUMX (
    ADDCOLUMNS (
        SUMMARIZE (
            'Fact Table',
            'Fact Table'[Industry],
            'Fact Table'[Scenario],
            "Diff", [Diff]
        ),
        "x", IF ( [Diff] > 0, [Diff] )
    ),
    [x]
)

 

danextian_0-1660539846149.png

 

Alternative formula

Total Increase =
CALCULATE (
    [Diff],
    FILTER (
        SUMMARIZE ( 'Fact Table', 'Fact Table'[Industry], 'Fact Table'[Scenario] ),
        VAR _diff = [Diff] RETURN _diff > 0
    )
)









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian  Thank you a lot for your suggestion, I test it, I need in "Total Increase" column always show total value "128" (total of all Industry where they are Diff >0) , then use this value to calculate for "Increase%", Do you have any idea, Thank you again

wangjuan303_0-1660565880967.png

 

So what you want is to have 128 in all rows? Try this:

Total Increase ALL = 
CALCULATE (
    [Diff],
    FILTER (
        ALL ( 'Fact Table'[Industry], 'Fact Table'[Scenario] ),
        VAR _diff = [Diff] RETURN _diff > 0
    )
)

danextian_0-1660566938705.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank you so much, How can we just show Industry where Diff>0,  for example, in this report, "Total Increase ALL" should  like Total Increase show blank, 

wangjuan303_0-1660573257552.png

 

You can use and IF condition so it returns blank for those with negative [Diff]

Total Increase ALL =
IF (
    [Diff] > 0,
    CALCULATE (
        [Diff],
        FILTER (
            ALL ( 'Fact Table'[Industry], 'Fact Table'[Scenario] ),
            VAR _diff = [Diff] RETURN _diff > 0
        )
    )
)

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank you for your help

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.