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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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