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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
erhan_79
Post Prodigy
Post Prodigy

Calculating violation

Hi there ;

 

i need your kind support for below issue pls : 

 

i have table as below , the yellow marked last colum that i want to create in my table.I need dax formula for column , not measure.

 

So pls let me explain what is this table and in which rules i need yellow column.

 

in this table there are materials that indexed as group for each them , there are request quantities and request dates  , delivery quantities and  delivery dates ,

" open quantity" column shows : request quantity -delivery quantity

"statu"  column shows that  if all the materials delivered or not , if all material delivered closed , if not open.

 

i  would like to find if there is violation while delivering quantities.So rules like that : 

 

  • IF the status is "open" system will check next all row's delivery quantity for each material , every checking will be for the material that we are on .  if there is even 1 pcs delivery quantity in next rows  system will write last column " violation" , if there is o ay delivered quantity in all next lines then here will be blank
  • If the status is "closed" , system will check request delivery date ad will compare delivery date of the next line's.If in the one next lines there will be a delivery date earlier than its own  request date again system will write "violation" , if not will be blank
  • For each material for the lastest row system will write blank that yellow column

 

Capture.JPG

 

to make your calculation easier i am sharig with you excels ource as below :

 

https://drive.google.com/file/d/1252yy235azu94tCWCUDAbjI3f1FPEqvy/view?usp=sharing

 

i hope it is clear thanks in advance for your kind help

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @erhan_79 ,

I assume this DAX statement allows to create a calculated column that returns what you are looking for:

violation = 
var __Material = 'Table'[Material]
var __Index = 'Table'[Index]
var __Status =  'Table'[Status]
var __DeliveryDate = 'Table'[Delivery Date]
var doSucceedingDeliveriesExist =
    IF( __Status = "Open"
        , IF(
            CALCULATE( 
                MAX( 'Table'[Delivery Quantity] )
                , FILTER(
                    ALL( 'Table')
                    , 'Table'[Material] = __Material && 'Table'[Index] > __Index
                )
            ) > 0
            , "Violation"
            , BLANK()
        )
    )
var doOpenPreceedingDeliveriesExist =
    IF( __Status = "Closed"
        , IF(
            CALCULATE( 
                MIN( 'Table'[Delivery Date] )
                , FILTER(
                    ALL( 'Table')
                    , 'Table'[Material] = __Material && 'Table'[Index] > __Index
                )
            ) <= __DeliveryDate
            , "Violation"
            , BLANK()
        )
    )
return
IF( doSucceedingDeliveriesExist = "Violation" || doOpenPreceedingDeliveriesExist = "Violation"
    , "Violation"
    , BLANK()
)

Here is a screenshot of the result, be aware that I call the column violation:

image.png

Hopefully, this provides what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey @erhan_79 ,

I assume this DAX statement allows to create a calculated column that returns what you are looking for:

violation = 
var __Material = 'Table'[Material]
var __Index = 'Table'[Index]
var __Status =  'Table'[Status]
var __DeliveryDate = 'Table'[Delivery Date]
var doSucceedingDeliveriesExist =
    IF( __Status = "Open"
        , IF(
            CALCULATE( 
                MAX( 'Table'[Delivery Quantity] )
                , FILTER(
                    ALL( 'Table')
                    , 'Table'[Material] = __Material && 'Table'[Index] > __Index
                )
            ) > 0
            , "Violation"
            , BLANK()
        )
    )
var doOpenPreceedingDeliveriesExist =
    IF( __Status = "Closed"
        , IF(
            CALCULATE( 
                MIN( 'Table'[Delivery Date] )
                , FILTER(
                    ALL( 'Table')
                    , 'Table'[Material] = __Material && 'Table'[Index] > __Index
                )
            ) <= __DeliveryDate
            , "Violation"
            , BLANK()
        )
    )
return
IF( doSucceedingDeliveriesExist = "Violation" || doOpenPreceedingDeliveriesExist = "Violation"
    , "Violation"
    , BLANK()
)

Here is a screenshot of the result, be aware that I call the column violation:

image.png

Hopefully, this provides what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

This is exactly what i look for , thank you very much @TomMartens !

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.