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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
KrilleGTI
New Member

New user needs help with DAX

Hi 

I need some help on how to programme a new meassure or table/column.

I have a table with the columns named CompanyID, Values and Date.  I would like to calculate the difference in percentage between the average of values for the oldest date for each row. I have no problem creating it in Excel but I want to use it in Power bi together with a slider for CompanyIDs and Dates. Expecting the result is the orange coloured table.


KrilleGTI_1-1707906753756.png

 

/Christian

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @KrilleGTI 

 

Based on your information, I create a table

 

vyohuamsft_0-1707993933193.png

 

Then I create a new measure named Average value by date

vyohuamsft_1-1707993933195.png

 

 

Based on your requirements, I've created a measure, and here's a preview of me

 

1.1.png

 

Here is my DAX

Measure = var a=MAXX(FILTER(ALLSELECTED('Table'),[Date]<MAX('Table'[Date])),[Date])

var b=CALCULATE([Average value by date],'Table'[Date]=MINX(ALLSELECTED('Table'),[Date]))

RETURN DIVIDE([Average value by date],b)-1

 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @KrilleGTI 

 

Based on your information, I create a table

 

vyohuamsft_0-1707993933193.png

 

Then I create a new measure named Average value by date

vyohuamsft_1-1707993933195.png

 

 

Based on your requirements, I've created a measure, and here's a preview of me

 

1.1.png

 

Here is my DAX

Measure = var a=MAXX(FILTER(ALLSELECTED('Table'),[Date]<MAX('Table'[Date])),[Date])

var b=CALCULATE([Average value by date],'Table'[Date]=MINX(ALLSELECTED('Table'),[Date]))

RETURN DIVIDE([Average value by date],b)-1

 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Works perfect, Thanks!

 

KrilleGTI
New Member

How can I attach my Power BI file? I have it almost working just need some help with pecentage calculation.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors