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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
MrAnderson72
Frequent Visitor

Return a calculated Value from a conditional and filtered maxx

Hello,

I have the table below and the following situation, please help me!

  • The table is extracted from the DB (except for the last column, which is the expected result)
  • I have a process where the Total is the number of non conformities (NCs) found into an Assessment
  • The following Assessment are linked with the original one by the column "ID" (same number)
  • I need to have a column with the number of NC reduced from last assessment (Initial Assessments are always zero)
  • Basically, current line "Total" minus last assessment "Total" (same ID and highest SubID # from all the Sub IDs that are lower from the current one)
  • The "Sub ID" is sequential but based on all the rows.

I tried to use MAXX with Filter, but with no success. Please, show me the way for solving this!!!

 

    (Expected Result)
IDSub IDTotalAssessmentReduction
116Initial0
155Post1
1124Post1
1172Post2
228Initial0
267Post1
2182Post5
385Initial0
3152Post3
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MrAnderson72 , Create a new column

new column =
var _min = maxx(filter(Table, [ID] =earlier([ID]) && [Sub ID] < earlier([Sub ID])),[Sub ID])
var _2 =maxx(filter(Table, [ID] =earlier([ID]) && [Sub ID] =_min),[Total])
return
if(isblank(_2), 0,_2-[Total])

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

1 REPLY 1
amitchandak
Super User
Super User

@MrAnderson72 , Create a new column

new column =
var _min = maxx(filter(Table, [ID] =earlier([ID]) && [Sub ID] < earlier([Sub ID])),[Sub ID])
var _2 =maxx(filter(Table, [ID] =earlier([ID]) && [Sub ID] =_min),[Total])
return
if(isblank(_2), 0,_2-[Total])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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