Forum Discussion
Advice on creating new summary table, based on filtering data from 2 other tables.
| Region | Total Sites | Expected Assets | Pending Sites |
| North | 3 | 75 | 1 |
| South | 2 | 50 | 1 |
| East | 1 | 25 | 1 |
| West | 5 | 125 | 3 |
Sample Data:
| Locations[id] | Locations[Region] | Locations[SiteCount] | Locations[Status] |
| 1 | North | 25 | |
| 2 | North | 25 | Complete |
| 3 | North | 25 | Complete |
| 4 | South | 25 | |
| 5 | South | 25 | Complete |
| 6 | East | 25 | |
| 7 | West | 25 | |
| 8 | West | 25 | |
| 9 | West | 25 | |
| 10 | West | 25 | |
| 11 | West | 25 | Complete |
| Assets[Location_id] | Assets[InventoryDate] |
| 1 | 7/4/1976 |
| 1 | 7/4/1976 |
| 1 | 7/4/1976 |
| 1 | 7/4/1976 |
| 1 | 7/4/1976 |
| 2 | 1/1/2023 |
| 2 | 1/1/2023 |
| 2 | 1/1/2023 |
| 4 | 7/4/1976 |
| 4 | 7/4/1976 |
| 4 | 7/4/1976 |
| 5 | 7/4/1976 |
| 5 | 7/4/1976 |
| 5 | 7/4/1976 |
| 5 | 7/4/1976 |
| 5 | 7/4/1976 |
| 5 | 7/4/1976 |
| 6 | 7/4/1976 |
| 6 | 7/4/1976 |
| 6 | 7/4/1976 |
| 7 | 7/4/1976 |
| 7 | 7/4/1976 |
| 7 | 7/4/1976 |
| 7 | 7/4/1976 |
| 8 | 7/4/1976 |
| 8 | 7/4/1976 |
| 8 | 7/4/1976 |
| 8 | 7/4/1976 |
| 9 | 7/4/1976 |
| 9 | 7/4/1976 |
| 9 | 7/4/1976 |
| 9 | 7/4/1976 |
| 10 | 1/1/2023 |
| 10 | 1/1/2023 |
| 10 | 1/1/2023 |
| 10 | 1/1/2023 |
| 11 | 1/1/2023 |
| 11 | 1/1/2023 |
| 11 | 1/1/2023 |
| 11 | 1/1/2023 |
- Anonymous2 years ago
Hi InventoryMan ,
Here are the steps you can follow:
1. Create calculated table.
Table = var _column= SELECTCOLUMNS( FILTER(ALL(Assets), 'Assets'[InventoryDate]=DATE(1976,7,4)),"Column_ID",'Assets'[Location_id]) var _table1= SUMMARIZE( 'Locations','Locations'[Region], "Total Sites",COUNT('Locations'[id]), "Expected Assets",SUM('Locations'[SiteCount]), "Pending Sites",COUNTX(FILTER(ALL(Locations),'Locations'[id] in _column&&'Locations'[Status]<>"Complete"&&'Locations'[Region]=EARLIER('Locations'[Region])),[Region])) return _table12. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
5 Replies
- amitchandak
Super User
InventoryMan , Try like
SUMMARIZECOLUMNS(Locations[Region],
"Total Sites", COUNT('Locations'[Id]),
"Expected Assets", SUM('Locations'[SiteCount]),
"Pending Sites", COUNT('Locations'[Id]),
Filter(Assets, Assets[InventoryDate] = DATE(1976, 7, 4) )
Filter(Locations, Locations[Status] <> 'complete')
)refer
https://www.sqlbi.com/articles/introducing-summarizecolumns/
- InventoryManFrequent Visitor
amitchandak Thank you, but I still receive an error for the filter. I will add some sample data, and perhaps there is another way to accomplish what I am looking for.
- InventoryManFrequent Visitor
Desired end result, and sample datat tables added.
- AnonymousNot applicable
Hi InventoryMan ,
Here are the steps you can follow:
1. Create calculated table.
Table = var _column= SELECTCOLUMNS( FILTER(ALL(Assets), 'Assets'[InventoryDate]=DATE(1976,7,4)),"Column_ID",'Assets'[Location_id]) var _table1= SUMMARIZE( 'Locations','Locations'[Region], "Total Sites",COUNT('Locations'[id]), "Expected Assets",SUM('Locations'[SiteCount]), "Pending Sites",COUNTX(FILTER(ALL(Locations),'Locations'[id] in _column&&'Locations'[Status]<>"Complete"&&'Locations'[Region]=EARLIER('Locations'[Region])),[Region])) return _table12. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- InventoryManFrequent Visitor
Thank you for your assistance on this! I have now been learning about the provided syntax.