Forum Discussion
Total difference between current and previous date
- 6 years ago
Hi Anonymous ,
We can use the following measure to meet your requirement:
Total Closed = CALCULATE ( DISTINCTCOUNT ( 'Table'[Number] ), FILTER ( 'Table', [State] = "Closed" ) )total closed since last snapshot date = VAR currentSnapshotDate = MAX ( 'Table'[SnapshotDate] ) VAR lastSnapshotDate = CALCULATE ( MAX ( 'Table'[SnapshotDate] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[SnapshotDate] < currentSnapshotDate ) ) RETURN CALCULATE ( DISTINCTCOUNT ( 'Table'[Number] ), FILTER ( 'Table', 'Table'[Created].[Date] <= currentSnapshotDate && 'Table'[Created].[Date] > lastSnapshotDate && 'Table'[State] = "Closed" ) ) + 0Total Open = CALCULATE ( DISTINCTCOUNT ( 'Table'[Number] ), FILTER ( 'Table', [State] = "Open" ) )total open since last snapshot date = VAR currentSnapshotDate = MAX ( 'Table'[SnapshotDate] ) VAR lastSnapshotDate = CALCULATE ( MAX ( 'Table'[SnapshotDate] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[SnapshotDate] < currentSnapshotDate ) ) RETURN CALCULATE ( DISTINCTCOUNT ( 'Table'[Number] ), FILTER ( 'Table', 'Table'[Created].[Date] <= currentSnapshotDate && 'Table'[Created].[Date] > lastSnapshotDate && 'Table'[State] = "Open" ) ) + 0Total calls = DISTINCTCOUNT('Table'[Number])Running Total calls = VAR snapshotDate = MAX ( 'Table'[SnapshotDate] ) RETURN CALCULATE ( DISTINCTCOUNT ( 'Table'[Number] ), FILTER ( ALLSELECTED ( 'Table' ), [SnapshotDate] <= snapshotDate ) )
BTW, pbix as attached.Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
We can use the following measure to meet your requirement:
Total Closed =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Number] ),
FILTER ( 'Table', [State] = "Closed" )
)
total closed since last snapshot date =
VAR currentSnapshotDate =
MAX ( 'Table'[SnapshotDate] )
VAR lastSnapshotDate =
CALCULATE (
MAX ( 'Table'[SnapshotDate] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[SnapshotDate] < currentSnapshotDate )
)
RETURN
CALCULATE (
DISTINCTCOUNT ( 'Table'[Number] ),
FILTER (
'Table',
'Table'[Created].[Date] <= currentSnapshotDate
&& 'Table'[Created].[Date] > lastSnapshotDate
&& 'Table'[State] = "Closed"
)
) + 0
Total Open =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Number] ),
FILTER ( 'Table', [State] = "Open" )
)
total open since last snapshot date =
VAR currentSnapshotDate =
MAX ( 'Table'[SnapshotDate] )
VAR lastSnapshotDate =
CALCULATE (
MAX ( 'Table'[SnapshotDate] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[SnapshotDate] < currentSnapshotDate )
)
RETURN
CALCULATE (
DISTINCTCOUNT ( 'Table'[Number] ),
FILTER (
'Table',
'Table'[Created].[Date] <= currentSnapshotDate
&& 'Table'[Created].[Date] > lastSnapshotDate
&& 'Table'[State] = "Open"
)
) + 0
Total calls =
DISTINCTCOUNT('Table'[Number])
Running Total calls =
VAR snapshotDate =
MAX ( 'Table'[SnapshotDate] )
RETURN
CALCULATE (
DISTINCTCOUNT ( 'Table'[Number] ),
FILTER ( ALLSELECTED ( 'Table' ), [SnapshotDate] <= snapshotDate )
)
BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks v-lid-msft , this worked perfectly where I tweaked a bit due to what was expected but it was nothing wrong with your DAX code. More imporantly I understood the concept of using variables and jumping between current and previous row. This concept will have long lasting impacts I believe because i am going to use it a lot.
Thanks a lot for your support.