cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SAPpowerbi
Helper I
Helper I

duplicate values count based on another column values

Hello Team ,

 

I want count based on business line  for category 1,Please help me to write a dax column .

Please find below tabel for example.

I want output based on category 1 and business Line column .

Category 1Category 2Business Line
AABExport
AACImport
BAAExport
CAMExport
DAAExport 
DBBImport
DCCExport

 

Please find below expecated output .

 

Category 1Ctegory 2Business LineCalculated column
AABExport2
AACImport2
BAAExport1
CAMExport1
DAAExport 3
DBBImport3
DCCExport3

 

In above output categort 1 - is "A" so A is come 2 times under business line -Import and export so my count is "2".

same for Cetegory 1  - "C" come 1 time under business line is only "Export" so my count is "1" .

 

Please help me to write a dax calulted column .

 

Thank you in advance . 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @SAPpowerbi 

 

You can try the following methods.

Column =
CALCULATE (
    COUNT ( 'Table'[Category 1] ),
    FILTER ( 'Table', [Category 1] = EARLIER ( 'Table'[Category 1] ) )
)

vzhangti_0-1664443737699.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

5 REPLIES 5
v-zhangti
Community Support
Community Support

Hi, @SAPpowerbi 

 

You can try the following methods.

Column =
CALCULATE (
    COUNT ( 'Table'[Category 1] ),
    FILTER ( 'Table', [Category 1] = EARLIER ( 'Table'[Category 1] ) )
)

vzhangti_0-1664443737699.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

philouduv
Resolver II
Resolver II

Hey there,

Try this : 

new_column = Calculate(COUNTROWS(Table),FILTER(Table,
Table[Category 1] == EARLIER(Table[Category 1])))

In red is what you have to adapt to your data model.

Best regards,

johnt75
Super User
Super User

Try

Calc column =
CALCULATE (
    COUNTROWS ( 'Table' ),
    ALLEXCEPT ( 'Table', 'Table'[Category 1], 'Table'[Business Line] )
)


Hi thank you for quik responce .

Need small help on the same dax = like category1  A two times and business line is Export and Import so my expected count is 2 , as per your dax its counting 1 

 

Your dax output is like below =

 

Category 1Business Linecalculated column
AExport 1
AImport 1

 

I need below output 

 

Category 1Category 2Business Linecalculated column
AABExport 2
AAcImport2

 

*** Note - I want Category1 with multiple business line so it will give me count .

I want output like above kindly help , Thnk you .

Try changing it to

Calc column =
CALCULATE (
    COUNTROWS ( 'Table' ),
    ALLEXCEPT ( 'Table', 'Table'[Category 1] )
)

Helpful resources

Announcements
collabdays lisbon

CollabDays Lisbon - 26 November 2022

Sessions include practical, hands-on experience that will help you take the next step in your career and know-how.

Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.