Hi, I'm having trouble with generating the first date of discrepancy stock between two softwares. That's mean, I want to write a DAX formula that returns the date of which the gap first happens.
The date that i want is 19/03 for this example below taken in account that a gap happened before on 14/02and it was regulated. Thanks for your help.
Solved! Go to Solution.
If you want to add a calculated column in powerpivot, try to change the measure formula as below:
Result= VAR currentValue = CALCULATE ( LASTNONBLANK ( Table1[Gap], 1 ), ALL ( 'Table1' ) ) VAR lastNonGap = CALCULATE ( MAX ( 'Table1'[Date] ), FILTER ( ALL ( 'Table1' ), 'Table1'[Gap] = 0 ) ) RETURN IF ( currentValue = 1, CALCULATE ( MIN ( 'Table1'[Date] ), FILTER ( ALL ( 'Table1' ), 'Table1'[Gap] = 1 && 'Table1'[Date] > lastNonGap ) ) )
Community Support Team _ Eason
Thanks for your help.
I would like to know if it is possible to work with measures because the table in the example is actually a pivot table.
The solution that you gave to me works fine. So grateful for that! but i have a problem with a particular case when i always have a discrepancy of stock (which means the earliest date is actually the first date a discrepancy happen). I'll give you an exemple of this case below. Thanks a lot for any help!
The result would be 12/05/2022
You can create a measure like
Discrepancy date = var currentValue = SELECTCOLUMNS( TOPN(1, 'Table', 'Table'[Date], DESC), "@val", 'Table'[Gap]) return IF( currentValue = 1, var lastNonGap = CALCULATE( MAX('Table'[Date]), 'Table'[Gap] = 0) return CALCULATE( MIN('Table'[Date]), 'Table'[Gap] = 1, 'Table'[Date] > lastNonGap ) )
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!
130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.