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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How to write a dax code that sums only greather than 0 en less than 0

Dear Power BI users,


I have writed a dax code/measure where I subtracted column A from B, that results in C. Now I would like to sum up only the values that are greather than zero >0 using the dax measure C. In the picture below you can see the positives and the negatives. Please help me with making a measure for this, no calculated columns please.

My measure C is: 

Price difference COGS = [Old cogs x current demand]-[New cogs x current demand]
 

Measure C looks like this:      Itemnr    Price difference COGS
                                                1              20
                                                 2              10
                                                 3              0
                                                 4              -5

How can i use my current measure "Price difference COGS = [Old cogs x current demand]-[New cogs x current demand]" to write a new measure that filters out everything above 0 that would result in 30 and the other way around (other measure) that should result in -5?

Your sincerely,
Baris

 
 
 
1 ACCEPTED SOLUTION

@Anonymous ,

 

Try it:

 

Price difference COGS = SUMX(FILTER('Fact table'; [Old cogs x current demand]-[New cogs x current demand] > 0); [Old cogs x current demand]-[New cogs x current demand])
 
Ricardo


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

Proud to be a Super User!



View solution in original post

11 REPLIES 11

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors