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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
smpa01
Super User
Super User

Show aggregation from left table but only for values appear on lookup table

My sample source data is following (pbix attached) - https://drive.google.com/file/d/1PXMUglwo2VElWUOcvr8wEWpBgGoA0meG/view?usp=sharing

 

|                key                      |
|-------|---------|-------|---------------|
| site  | service | month | key           |
| site1 | serv1   | 1     | site1-serv1-1 |
| site1 | serv1   | 2     | site1-serv1-2 |
| site1 | serv1   | 3     | site1-serv1-3 |
| site1 | serv1   | 4     | site1-serv1-4 |
| site1 | serv1   | 5     | site1-serv1-5 |
| site2 | serv1   | 1     | site2-serv1-1 |
| site2 | serv1   | 2     | site2-serv1-2 |
| site2 | serv1   | 3     | site2-serv1-3 |
| site2 | serv1   | 4     | site2-serv1-4 |
| site3 | serv1   | 1     | site3-serv1-1 |
| site3 | serv1   | 2     | site3-serv1-2 |
| site3 | serv1   | 3     | site3-serv1-3 |
| site3 | serv1   | 4     | site3-serv1-4 |
| site3 | serv1   | 5     | site3-serv1-5 |
| site3 | serv1   | 6     | site3-serv1-6 |
| site3 | serv1   | 7     | site3-serv1-7 |
| site4 | serv1   | 1     | site4-serv1-1 |
| site4 | serv1   | 2     | site4-serv1-2 |
| site4 | serv1   | 3     | site4-serv1-3 |
| site4 | serv1   | 4     | site4-serv1-4 |
| Lookup |
|--------|
| site   |
| site1  |
| site3  |
| site4  |

 

 

I am building a matrix viz by bringing site,service,month from key tbl and counting how many total months are there by each site-service but I only want to show the  aggregation for sites that only appear in Lookup.

 

My measures are following and this is what I get after dropping the measure which I don't want.

 

countSiteService:=
CALCULATE ( COUNT ( 'key'[month] ), REMOVEFILTERS ( 'key'[month] ) )

countSiteServiceLookup =
CALCULATE (
    [countSiteService],
    TREATAS ( VALUES ( Lookup[site] ), 'key'[site] )
)

 

 

Capture.PNG

 

My desired result is following

 

|            Result                |
|--------|---------|-------|-------|
| site   | service | month | Count |
| site1  | serv1   | 1     | 5     |
| site1  | serv1   | 2     | 5     |
| site1  | serv1   | 3     | 5     |
| site1  | serv1   | 4     | 5     |
| site1  | serv1   | 5     | 5     |
| site3  | serv1   | 1     | 7     |
| site3  | serv1   | 2     | 7     |
| site3  | serv1   | 3     | 7     |
| site3  | serv1   | 4     | 7     |
| site3  | serv1   | 5     | 7     |
| site3  | serv1   | 6     | 7     |
| site3  | serv1   | 7     | 7     |
| site4  | serv1   | 1     | 4     |
| site4  | serv1   | 2     | 4     |
| site4  | serv1   | 3     | 4     |
| site4  | serv1   | 4     | 4     |

 

 

Thank you in advance.

  @AlexisOlson 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
smpa01
Super User
Super User

Resolved here, credit to @AlexisOlson 

 

https://stackoverflow.com/questions/69194893/dax-to-aggregate-only-for-values-from-lookup-table/6919...

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

4 REPLIES 4
smpa01
Super User
Super User

Resolved here, credit to @AlexisOlson 

 

https://stackoverflow.com/questions/69194893/dax-to-aggregate-only-for-values-from-lookup-table/6919...

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
amitchandak
Super User
Super User

@smpa01 , Try like

countSiteServiceLookup =
CALCULATE (
[countSiteService],
filter('Key', 'key'[site] in values(Lookup[site] ))
)

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

It does not keep the previouly created count by partition @amitchandak 

 

smpa01_0-1631723192624.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
smpa01
Super User
Super User

I can do this, but it does not give me correct total count in the subtotal level

countSiteService = 
VAR _lookupSite = CALCULATE(max(Lookup[site]),CROSSFILTER('key'[site],Lookup[site],Both))
VAR _res = CALCULATE ( COUNT ( 'key'[month] ), REMOVEFILTERS('key'[month]),'key'[site]=_lookupSite)
RETURN _res

 

capx.PNG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors