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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
BB9
Frequent Visitor

DAX expression help

Hi,

I am trying to generate a new column based on two other columns, and not able to get this to work.

 

Item1     1/1/21     8

Item1      1/1/21    8

Item1      1/1/21    8

Item1     1/2/21     9

Item1      1/2/21    9

Item2     1/1/21     10

Item2      1/1/21    10

Item2     1/2/21     8

Item2      1/2/21    8

 

 

Desired Output:

Item1     1/1/21     8

Item1      1/1/21    0

Item1      1/1/21    0

Item1     1/2/21     9

Item1      1/2/21    0

Item2     1/1/21     10

Item2      1/1/21    0

Item2     1/2/21     8

Item2      1/2/21    0

 

Basically, a new column should show the average of the number per item per date in one column and the other columns as 0 for the remaining rows for the same item and date.

 

Hope my question is not confusing.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@BB9 , first you need to add an index in the power query.

 

Then a new column

new column =
var _min = minx(filter(Table, [item] = earlier([item]) && [date] = earlier([date])),[Index])
var _avg = minx(filter(Table, [item] = earlier([item]) && [date] = earlier([date])),[value])
return
if([Index] =_min, _avg, blank())

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

View solution in original post

2 REPLIES 2
BB9
Frequent Visitor

Thank you @amitchandak for the quick response. It worked like a gem!

amitchandak
Super User
Super User

@BB9 , first you need to add an index in the power query.

 

Then a new column

new column =
var _min = minx(filter(Table, [item] = earlier([item]) && [date] = earlier([date])),[Index])
var _avg = minx(filter(Table, [item] = earlier([item]) && [date] = earlier([date])),[value])
return
if([Index] =_min, _avg, blank())

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors