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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
alson2002
New Member

how to calculate with specific filter

Hello Team,

 

I tried to get the previous row value of column "P" based on column "Year" with below DAX to add NEW column "Previous_P",

 

Statistic Group IDYearP
11204220210
11204220220
11204220230
1120422024164.74
1120422025159.8
1120422026155.01
1120422027150.36
1120422028145.85
13716520210
13716520220
13716520230
13716520240
13716520258525.5
13716520268270.5
13716520278024
13716520287862.5

 

 

 

Previous_P = SUMX(FILTER(Sheet1,Sheet1[Year]=EARLIER(Sheet1[Year])-1),Sheet1[P])

 

 

 

after applying above DAX, I could get the below result:

2021-10-18_14h15_17.png

 

 

 

 

 

 

 

 

 

 

 

 

 

but what I want is to get "previous_P" with group of different value of "Statistic Group ID".

alson2002_0-1634538316459.png

I tried to use DAX as below, but could not get the expected data:

 

 

 

 

Previous_P = 
CALCULATE(
SUMX('Sheet1',Sheet1[P]),
FILTER(Sheet1,Sheet1[Year]=(Sheet1[Year])-1),ALLEXCEPT(Sheet1,Sheet1[Statistic Group ID])
)

 

 

 

 

 

Could you support to propose how I can get the expected data?

Thank you!

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@alson2002 , Try like 

 

Previous_P = SUMX(FILTER(Sheet1,Sheet1[Year]=EARLIER(Sheet1[Year])-1 && Sheet1[Statistic Group ID] =  earlier(Sheet1[Statistic Group ID] ) ),Sheet1[P])

 

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
amitchandak
Super User
Super User

@alson2002 , Try like 

 

Previous_P = SUMX(FILTER(Sheet1,Sheet1[Year]=EARLIER(Sheet1[Year])-1 && Sheet1[Statistic Group ID] =  earlier(Sheet1[Statistic Group ID] ) ),Sheet1[P])

 

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

Great, thank you!!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.