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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
vm8181
Frequent Visitor

Trying to achieve listed & not listed count

I have data model where I have two tables Dim_Product and Fact_sales with one to many relationship on the basis of productCode. 

I am trying to achieve listed & not listed(where sales are available listed else not listed). It's showing fine for platform wise, but not giving appropriate values for city wise.
SKU_Code or product name is the attribute which is common across platform.


Dim_Product Table

 

ProductCodeSKUCodeProductNameCategoryPlatform
P001_AMZSKU001Smart WatchElectronicsAmazon
P001_FLKSKU001Smart WatchElectronicsFK
P002_AMZSKU002Wireless EarbudsElectronicsAmazon
P002_FLKSKU002Wireless EarbudsElectronicsFK
P003_AMZSKU003Yoga MatSportsAmazon
P003_FLKSKU003Yoga MatSportsFK
P004_AMZSKU004Running ShoesSportsAmazon
P004_FLKSKU004Running ShoesSportsFK
P005_AMZSKU005Vacuum CleanerHome AppliancesAmazon
P005_FLKSKU005Vacuum CleanerHome AppliancesFK
P006_AMZSKU006BlenderHome AppliancesAmazon
P006_FLKSKU006BlenderHome AppliancesFK


Fact_Sales Table

 

PlatformProductCodeCitySales
FKP001_FLKLos Angeles1400
AmazonP002_AMZChicago2000
FKP002_FLKHouston1900
FKP003_FLKSan Francisco1300
AmazonP004_AMZSeattle1700
AmazonP005_AMZAustin2500
FKP005_FLKBoston2400
AmazonP006_AMZDenver1100
AmazonP001_AMZDallas1550
FKP001_FLKDetroit1450
AmazonP002_AMZPhoenix2100


Measure

Sales = SUM(Sales)
Status = SWITCH(TRUE(), ISBLANK([_sales]), "Not Listed", "Listed")

Listed =
CALCULATE(
    COUNTROWS(Dim_Master),
    FILTER(
        Dim_Master,
        [status] = "Listed"
    )
)
Note Listed =
CALCULATE(
    COUNTROWS(Dim_Master),
    FILTER(
        Dim_Master,
        [status] = "Not Listed"
    )
)

I have attached a screenshot for the reference.


vm8181_0-1732974534014.png

Any help would be greatful. Thank you so much.

 

4 REPLIES 4
vm8181
Frequent Visitor

Hi @Ashish_Mathur , @Selva-Salimi , @Anonymous Thanks for your responses.
The problem has solved. 


Let me clear my explanation for better understanding.

Scenario:
-I have two tables: dim_product and fact_sales. My goal is to show listed and not listed products for different platforms and cities, considering whether sales are available or not.

 

-Platforms exist in dim_product, and there is a direct relationship(1 - to - many) between dim_product and fact_sales based on product code. So, calculating listed and not listed products for platforms works correctly.


-However, cities are only present in fact_sales. If I use cities from fact_sales, I will only see values where sales exist. Instead, I need a solution where cities with no sales also appear with a count of 0.

Solution Implemented:
To address this, I created a dim_city table in Power Query by referencing fact_sales and then designed measures accordingly.

Listed Products (for both Platforms and Cities)
Listed = CALCULATE(COUNT(Dim_Master[SKUCode]),FILTER(Fact_Sales, [_sales] <> 0))
This works correctly for both platforms and cities.

 

Not Listed Products (Separate Measures for Platforms & Cities)

 

For Platforms:
Not Listed Platform =
VAR status_ = SUMMARIZE(Dim_Master,Dim_Master[SKUCode],Dim_Master[ProductName],Dim_Master[Platform],
"sales", CALCULATE(SUM(Fact_Sales[Sales]) + 0))
VAR result = COUNTX(FILTER(status_, [sales] = 0),Dim_Master[SKUCode])
RETURN
result

 

For Cities:
Not Listed City =
VAR status_ = ADDCOLUMNS(CROSSJOIN(SUMMARIZE(Dim_Master, Dim_Master[SKUCode],Dim_Master[ProductName]), Cities),"sales", [_sales] + 0)
VAR result = COUNTX(FILTER(status_, [sales] = 0),Dim_Master[SKUCode])
RETURN
result

It's working correctly and filtering the values as expected.

vm8181_0-1740640905022.png

vm8181_1-1740640933516.png

 



Anonymous
Not applicable

Hi All,
Firstly @Ashish_Mathur  and @Selva-Salimi  thank you for yours solution!
And @vm8181 ,It looks like your problem is that the measure doesn't show up correctly when you use the city column, right?

vxingshenmsft_0-1733108089534.png

In our test environment, we tried to use your code and there seems to be no problem, it is possible that this problem occurs due to context filtering being affected, if you can provide example data or a pbix file, or make further modifications in the pbix file I uploaded to reproduce your problem, this will better help you solve the problem, I look forward to hearing from you!


 



 

Ashish_Mathur
Super User
Super User

Hi,

Based on the 2 tables that you have shared, show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Selva-Salimi
Solution Sage
Solution Sage

Hi @vm8181 

 

what is Dim_master table and what is the relation between this table and others?!

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.