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
Anonymous
Not applicable

DAX: MAX value for Item if value is 0

Hi everyone,

 

I'm trying to create a new column that will return the MAX value for an item in a particular Month & Year if the value is 0.

If the value is >0, it should return the same value.

In my case the value is the "Selling Price". Ideally, it should return the new column "Revised Selling Price for the Month".

blueraccoon_0-1627299873885.png

 

Thank you all!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

Revised SellingPrice CC =
VAR _currentitem = Data[Item]
VAR _currentmonth = Data[Month]
VAR _currentyear = Data[Year]
VAR _maxprice =
MAXX (
FILTER (
Data,
Data[Item] = _currentitem
&& Data[Month] = _currentmonth
&& Data[Year] = _currentyear
),
Data[SellingPrice]
)
RETURN
IF ( Data[SellingPrice] <> 0, Data[SellingPrice], _maxprice )
 
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Picture1.png

 

Revised SellingPrice CC =
VAR _currentitem = Data[Item]
VAR _currentmonth = Data[Month]
VAR _currentyear = Data[Year]
VAR _maxprice =
MAXX (
FILTER (
Data,
Data[Item] = _currentitem
&& Data[Month] = _currentmonth
&& Data[Year] = _currentyear
),
Data[SellingPrice]
)
RETURN
IF ( Data[SellingPrice] <> 0, Data[SellingPrice], _maxprice )
 
 
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

It works wonderfully thanks a lot!!

amitchandak
Super User
Super User

@Anonymous , Try a new column like


measure =
var _1 = maxx(filter(Table, [Month] =earlier([Month]) && [year] = earlier([year])), [selling price])
return
if([selling price] =0, _1, [selling price])

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.

Top Solution Authors