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

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
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.