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
gardas_swathi
Microsoft Employee
Microsoft Employee

Need Distinct count of Product ID based on Filter Criteria

Hi ,

 

I need help in figuring out the solution for a measure in Analysis Tabular Cube. CountProduct is the measure I am trying to create. I need to find count of products based on the below criteria ( scenarions listed in the table below) and the count should be visible at any grain when sliced. Also Grand Total should be just the total count of products for any given selection

 

Scenario NetSupply[Existing measure : Supply- Demand ]CountProduct
No Demand No Supply0Blank
Product With Supply and no Demand or 0 Zero Demand> 0Blank
Product With no Supply and has Demand< 00
Product with Supply and Demand01
Product with Supply and Demand<00
Product with Supply and Demand>01

 

Demand, Supply & Net Supply are existing measures in Cube. if a product is has 2 segment ID's and has demand and supply , I need to double count when looking at the higher grain which is why i used Summarize function to group by productid and segmentid. Below measure is showing just 0 even when demand and supply are available. 

 

CountProduct:=
VAR RowCount =COUNTROWS (
FILTER (
SUMMARIZE(FILTER('SupplyTable',[Demand]>0 && [Supply]>0), 'SupplyTable'[ProductID] ,'SupplyTable'[SegmentID]),
(
IF(
(
(ISBLANK([Demand])=TRUE
||[Demand]=0
)
&&
(ISBLANK([Supply])=TRUE
||[Supply]=0)
)
||
(
(ISBLANK([Demand])=TRUE
||[Demand]=0)
&&
[Supply]>0
)
,-1
,
IF
(
(ISBLANK([Demand])=FALSE
||[Demand]>0
)
&&
(ISBLANK([Supply])=TRUE
||[Supply]=0)
,[Demand]
,[Net Supply]

)
)>= 0
))
)
RETURN

IF (ISBLANK(RowCount)=TRUE &&[Net Supply]<0,0,RowCount)

 

I got solutions from @amitchandak  and @Greg_Deckler  before. Hope you can help even this time or even anyone in this forum

1 REPLY 1
Anonymous
Not applicable

Hi @gardas_swathi ,

 

Have trouble to follow, please share some sample data so that we could test formula.

 

Best Regards,

Jay

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.