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
gardas_swathi
Employee
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
v-jayw-msft
Community Support
Community Support

Hi @gardas_swathi ,

 

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

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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.

Top Solution Authors