Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
InventoryMan
Frequent Visitor

Advice on creating new summary table, based on filtering data from 2 other tables.

I have been trying to replicate a dashboard, previously created via MySQL. I am unable, or aware if what I am trying to replicate can be done.
 
The dashboard is "grouped by" Locations[Region]
There is a relationship created between 2 tables; Assets & Locations locations[id] = assets[location_id]
 
In some cases I am trying to FILTER the results, based on data in 1 or both tables. I cannot figure out the correct FILTER syntax, or if I'm even going about it the correct way. For the "Pending Sites" column I want to filter on the red text. I believe through trial and error I was able to get 1 filter, from the Locations table to work. I have been stuck adding 2 filters, and they are from 2 different tables.
 
SUMMARIZECOLUMNS(Locations[Region],
"Total Sites", COUNT('Locations'[Id]),
"Expected Assets", SUM('Locations'[SiteCount]),
"Pending Sites", COUNT('Locations'[Id]),
/*Assets[InventoryDate] = DATE(1976, 7, 4) AND Locations[Status] <> 'complete'*/
)
Desired Result:
RegionTotal SitesExpected AssetsPending Sites
North3751
South2501
East1251
West51253

 

Sample Data:

Locations[id]Locations[Region]Locations[SiteCount]Locations[Status]
1North25 
2North25Complete
3North25Complete
4South25 
5South25Complete
6East25 
7West25 
8West25 
9West25 
10West25 
11West25Complete

 

Assets[Location_id]Assets[InventoryDate]
17/4/1976
17/4/1976
17/4/1976
17/4/1976
17/4/1976
21/1/2023
21/1/2023
21/1/2023
47/4/1976
47/4/1976
47/4/1976
57/4/1976
57/4/1976
57/4/1976
57/4/1976
57/4/1976
57/4/1976
67/4/1976
67/4/1976
67/4/1976
77/4/1976
77/4/1976
77/4/1976
77/4/1976
87/4/1976
87/4/1976
87/4/1976
87/4/1976
97/4/1976
97/4/1976
97/4/1976
97/4/1976
101/1/2023
101/1/2023
101/1/2023
101/1/2023
111/1/2023
111/1/2023
111/1/2023
111/1/2023
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

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
_table1

2. Result:

vyangliumsft_0-1697681026212.png

 

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

View solution in original post

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

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
_table1

2. Result:

vyangliumsft_0-1697681026212.png

 

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

Thank you for your assistance on this! I have now been learning about the provided syntax.

InventoryMan
Frequent Visitor

Desired end result, and sample datat tables added.

amitchandak
Super User
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/

@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.

 

InventoryMan_0-1697550429712.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.