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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Charli
Frequent Visitor

Formula to agregate data

Hello all,

I am working on PBI desktop

I am trying to write a formula to agregate some numbers in a precise order. To define the order, I have added a column next to my data with the correct "order" (1, 2, 3 etc.).

I have wrote the following formula : 

 
Calculation = if('Calculation'[nbre lignes]=1,CALCULATE([In M€],ALL('PnL Conso (nature)','PnL Conso (nature)'[Num order 2]<VALUES('PnL Conso (nature)'[Num order 2]))))
 
But then Power Bi is sending me the following error :  It is impossible to determine a unique value for the "Num order 2" column in the "PnL Conso (nature)" table. This can happen when a measurement formula refers to a column that contains many values, without specifying an aggregation such as min, max, count or sum to get a unique result.
 
I would appreciate any help please,
 
Thank you!
1 ACCEPTED SOLUTION
Walter_W2022
Resolver II
Resolver II

Hi @Charli , please try this, I assumed you want to calculate running total based on the order, it will be great if you can provide more details or data.
Calculation = 
VAR _MaxNum = MAX('PnL Conso (nature)'[Num order 2])
VAR _RT =
if(
'Calculation'[nbre lignes]=1,
CALCULATE(
[In M€],
FILTER(
ALL('PnL Conso (nature)'),
'PnL Conso (nature)'[Num order 2]<_MaxNum
)
)
)
 
RETURN
_RT

View solution in original post

2 REPLIES 2
Walter_W2022
Resolver II
Resolver II

Hi @Charli , please try this, I assumed you want to calculate running total based on the order, it will be great if you can provide more details or data.
Calculation = 
VAR _MaxNum = MAX('PnL Conso (nature)'[Num order 2])
VAR _RT =
if(
'Calculation'[nbre lignes]=1,
CALCULATE(
[In M€],
FILTER(
ALL('PnL Conso (nature)'),
'PnL Conso (nature)'[Num order 2]<_MaxNum
)
)
)
 
RETURN
_RT
Dangar332
Super User
Super User

Hi, @Charli 

Please provide some data and what you want

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.