Forum Discussion
Missing Tickets
Here's what i've got for the dax:
Diff =
var previousTicket = CALCULATE(MAX('Table'[Ticket]), ALL('Table'[Ticket]), 'Table'[Ticket] < SELECTEDVALUE('Table'[Ticket]))
var previous = IF(ISBLANK(previousTicket), SELECTEDVALUE('Table'[Ticket]), previousTicket)
return CALCULATE(SUM('Table'[Ticket]) - previous)
- BudMan5123 years ago
Helper V
Hi Vicky,
Here is a screenshot of my real world data. I have substituted 'History'[HIST_REF_NO] for 'Table'[Ticket] in your script. As you can see, the calculation starts out fine but soon goes off the rails. I wonder if you see what the issue might be. Thanks for your help.
Bud
- BudMan5122 years ago
Helper V
Here is a link to the report I need help with. It is in OneDrive.
Below is a screenshot of the report. It is intended to identify missing invoices. The first invoice in a Batch should be a zero in the 'Diff' column and subseqent invoices should be the difference between an Invoice number and the previous Invoice number. Normally the difference should be 1 unless there are missing invoices. You can see in the below screenshot the first two batches are working perfectly and then it breaksdown. The Measure's DAX is below.
Diff =var previousTicket = CALCULATE(MAX('History'[Invoice]), ALL('History'[Invoice]), 'History'[Invoice] < SELECTEDVALUE('History'[Invoice]))var previous = IF(ISBLANK(previousTicket), SELECTEDVALUE('History'[Invoice]), previousTicket)return CALCULATE(SUM('History'[Invoice]) - previous)I need the report to calculate the difference between invoices accurately while making the diff for the first invoice of a new batch be zero. If anyone could help me with this, it would be greatly appreciated.