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
cgkas
Helper V
Helper V

Dax formula to count elements with multiple conditions

Good day everyone,

Maybe someone could help me. I have the following table

IDSTOREMODELSIZECODE_NUMRCODESCODE
0STORE_08DIAMONDTALL502609MENMTGGTG
0STORE_08PLATINUMTALL1312314WOMENACGUSG
1STORE_09DIAMONDSHORT775WOMENDMEHNE
2STORE_10DIAMONDSMALL775WOMENDMEHNE
3STORE_11PLATINUMSTANDARD1989707MENUD1DE1
3STORE_11PLATINUMSTANDARD532715WOMENRCNGBN
3STORE_11PLATINUMSTANDARD502991MENMTGGTG
3STORE_11PLATINUMTALL120631MENAW6US6
3STORE_11PLATINUMTALL1320334MENNOT IN STOCK
3STORE_11PLATINUMTALL31234MENUD1DE1
3STORE_11PLATINUMTALL47259MENMTGGTG


I'd like to get the count of unique (distincts) SCODES when ID = 5, RCODE = MEN and MODEL = PLATINUM

If in SCODE there are values = NOT IN STOCK then should be counted apart. Then the output I'm looking for is like this:

Total Distincts = 3
UD1DE1,MTGGTG,AW6US6
NOT IN STOCK = 1
1320334


If NOT IN STOCK = 0 and Total Distincts = 0 then the output would be

Total Distincts = 0


If NOT IN STOCK = 0 then and Total Distincts > 0 the output would be

Total Distincts = N (Where N > 0)


I've tried a measure like below but is not working

Measure = IF(VALUES(PRODS[SCODE]<>"NOT IN STOCK"),
DISTINCTCOUNT(PRODS[SCODE]),
COUNTAX(PRODS[SCODE],PRODS[SCODE]="NOT IN STOCK"))

Thanks in advance for any help

3 REPLIES 3
v-eachen-msft
Community Support
Community Support

Hi @cgkas ,

 

You could replace "VALUES" with "SELECTEDVALUE" because "VALUES" will return multi values in your case.

 

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

Hello, thanks for your answer.

 

I changed to SELECTEDVALUE, but is always showing 8, when should be 6.

 

 
IF(SELECTEDVALUE(PRODS[SCODE])<>"NOT IN STOCK",
DISTINCTCOUNT(PRODS[SCODE]))
Besides that, I'm far to get the desired output I'm looking for that is show the count of unique (distincts) SCODES when ID = 5, RCODE = MEN and MODEL = PLATINUM using DAX formula.
 
May you help me with this?
 
Thanks

 

cgkas
Helper V
Helper V

May someone could help me with this question please.

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.