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
Anonymous
Not applicable

Countx Function

 

Gentleman, I have faced some difficulties in finding Carrier Number.

From below sample table, I wanted Carrier operated per month by Customer shown in 2nd Table.

 

Customer Carrier Jan'19  Feb'19  Mar'19

A                A1                     400      500

B                A1       500                    200

C                A2       400        300      400

D               A3        700        600     700

 

Here I want to find out no of Carrier by per month by Customers. e.g if Career A1 used in Mar'19 by Two customer A & B, but it should be only one(no duplicate count) and same assigned to highest sales to Customer A.

 

Customer Carrier JanCarrier FebCarrier Mar
A 11
B100
C111
D111


Kindly Help to formulate CountX DAX function

 

Thanks,

K

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Take a try of this:

Measure 2 = var a = CALCULATE(MAX('Table'[Value]),ALL('Table'),VALUES('Table'[Carrier]),VALUES('Table'[Month]))
Return
IF(MAX('Table'[Value])=a,1,0)

0.PNG

Best regards,

Dina Ye

 

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

View solution in original post

4 REPLIES 4
v-diye-msft
Community Support
Community Support

Hi @Anonymous ,

 

I created a sample as your requested, plz use below measures to generate the results:

Measure1 = IF(ISBLANK(MAX([Jan'19])),0,COUNTX(Table1,[Jan'19]))
Measure2 = IF(ISBLANK(MAX([Feb'19])),0,COUNTX(Table1,[Feb'19]))
Measure3 = var a = CALCULATE(MAX([Mar'19]),ALL(Table1),VALUES(Table1[Carrier]))
var b = IF(MAX(Table1[Mar'19])=a,MAX(Table1[Mar'19]),BLANK())
Return
IF(ISBLANK(COUNTX(table1,b)),0,COUNTX(table1,b))
5.PNG
Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Thanks Dina, its really workout out.

 

Need one more help. which i have tried to do but couldn't get any success.

 

Suppose, if my Table is in another formate like instead of the month in Column it is in Row format then? i have tired to apply same code but failed.

 

appreciate your help if you can

 

Customer CarrierMonthValueCarrier Count**
AA1Jan'19 0
BA1Jan'195001
CA2Jan'194001
DA3Jan'197001
AA1Feb'194001
BA1Feb'19 0
CA2Feb'193001
DA3Feb'196001
AA1Mar'195001
BA1Mar'192000
CA2Mar'194001
DA3Mar'197001

Hi @Anonymous ,

 

Take a try of this:

Measure 2 = var a = CALCULATE(MAX('Table'[Value]),ALL('Table'),VALUES('Table'[Carrier]),VALUES('Table'[Month]))
Return
IF(MAX('Table'[Value])=a,1,0)

0.PNG

Best regards,

Dina Ye

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Thanks its works absolutely 🙂

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.