Forum Discussion
Delphia
Advocate II
5 years agoCircular dependency with calculated table
Hi, I have a problem with circular dependency that I don't know how to overcome. I have the following schema: "Date" table is autogenerated: Date = CALENDARAUTO() "Group by Date and ...
- Anonymous5 years ago
You can use the below measure to get the Previous Value without having to create the summarized table:
Previous Value =VAR CurrentDate = MAX(cleaned_row_count[Date])VAR ClientID = MAX('table'[id])VAR PreviousDate = CALCULATE(MAX(cleaned_row_count[Date]),ALL('Date'[Date]),ALL(cleaned_row_count[Date]),FILTER('Date',[Date]<CurrentDate))VAR Result = CALCULATE(SUM(cleaned_row_count[Number of Rows]),ALL('Date'[Date]),ALL(cleaned_row_count[Date]),FILTER('Date',[Date]=PreviousDate))RETURN ResultI couldn't understand the 'table' fields because you have an id field and then a client field. The client seems to repeat for different ids.. Anyway, if you want to work per client, you might need to replace table_id with client in the above measure - 5 years ago
- 5 years ago
Keep the previous measures (we will be using them in the final measures.
Number of rows (measure final) = VAR MaxDate = CALCULATE ( MAX ( cleaned_row_count[Date] ), ALLEXCEPT ( cleaned_row_count, 'table'[Client] ) ) VAR RowNumMax = CALCULATE ( [Number of rows (measure)], ALLEXCEPT ( cleaned_row_count, 'table'[Client] ), FILTER ( ALL ( 'Date' ), 'Date'[Date] = MaxDate ) ) RETURN SWITCH ( TRUE (), ISINSCOPE ( 'Date'[Date] ), [Number of rows (measure)], ISINSCOPE ( 'table'[Client] ), RowNumMax )Previous Date Rows (Final) = VAR MaxDate = CALCULATE ( MAX ( cleaned_row_count[Date] ), ALLEXCEPT ( cleaned_row_count, 'table'[Client] ) ) VAR RowNumMax = CALCULATE ( [Previous Date rows], ALLEXCEPT ( cleaned_row_count, 'table'[Client] ), FILTER ( ALL ( 'Date' ), 'Date'[Date] = MaxDate ) ) RETURN SWITCH ( TRUE (), ISINSCOPE ( 'Date'[Date] ), [Previous Date rows], ISINSCOPE ( 'table'[Client] ), RowNumMax )Diff in Rows vs Previous Date = [Number of rows (measure final)] - [Previous Date Rows (Final)]Attached is the new version of the PBIX file
Delphia
Advocate II
5 years agoIt should be value for the last available date in table (today). So, for client 1 it should be value for 5/18/2021:
Number of Rows = 66,137,151
Previous Day Rows = 66,088,701
Thank you!
PaulDBrown
Community Champion
5 years agoKeep the previous measures (we will be using them in the final measures.
Number of rows (measure final) =
VAR MaxDate =
CALCULATE (
MAX ( cleaned_row_count[Date] ),
ALLEXCEPT ( cleaned_row_count, 'table'[Client] )
)
VAR RowNumMax =
CALCULATE (
[Number of rows (measure)],
ALLEXCEPT ( cleaned_row_count, 'table'[Client] ),
FILTER ( ALL ( 'Date' ), 'Date'[Date] = MaxDate )
)
RETURN
SWITCH (
TRUE (),
ISINSCOPE ( 'Date'[Date] ), [Number of rows (measure)],
ISINSCOPE ( 'table'[Client] ), RowNumMax
)Previous Date Rows (Final) =
VAR MaxDate =
CALCULATE (
MAX ( cleaned_row_count[Date] ),
ALLEXCEPT ( cleaned_row_count, 'table'[Client] )
)
VAR RowNumMax =
CALCULATE (
[Previous Date rows],
ALLEXCEPT ( cleaned_row_count, 'table'[Client] ),
FILTER ( ALL ( 'Date' ), 'Date'[Date] = MaxDate )
)
RETURN
SWITCH (
TRUE (),
ISINSCOPE ( 'Date'[Date] ), [Previous Date rows],
ISINSCOPE ( 'table'[Client] ), RowNumMax
)Diff in Rows vs Previous Date = [Number of rows (measure final)] - [Previous Date Rows (Final)]
Attached is the new version of the PBIX file
- Delphia5 years ago
Advocate II
It works! Thank you so much!