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
gerasimovav
Helper III
Helper III

How to count rows with the same values in the column?

Hello, colleagues! 

I have such table:

iD           Action_Type         Data

1              15                       21.01.2018

2              25                       22.01.2018

3              33                       15.01.2018

4              25                       21.01.2018

5              15                       27.01.2018

6              33                       21.01.2018

7              25                       21.02.2018

 

etc.

I have to count the quantity of set where at the same date was happened three types of action (15, 25 and 33).  In this example the rusult is 1 because of 21.01.2018 happened actions 15 (id 1), 25 (id 4) and 33 (id 6).

How can I do that?

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

try this measure

Measure = 
VAR Dates = 
ADDCOLUMNS(
    ADDCOLUMNS(
        SUMMARIZE('Table','Table'[Data]),
        "15",CALCULATE(COUNT('Table'[Action_Type]),'Table'[Action_Type]=15),
        "25",CALCULATE(COUNT('Table'[Action_Type]),'Table'[Action_Type]=25),
        "33",CALCULATE(COUNT('Table'[Action_Type]),'Table'[Action_Type]=33)
        ),
    "CountSet",MIN(MIN([15],[25]),[33])
)
RETURN
SUMX(Dates,[CountSet])

it counts the occurences of the elements of the set per date

then picks the minimum of the count for each date
then sums up the the count numbers



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

4 REPLIES 4
Stachu
Community Champion
Community Champion

try this measure

Measure = 
VAR Dates = 
ADDCOLUMNS(
    ADDCOLUMNS(
        SUMMARIZE('Table','Table'[Data]),
        "15",CALCULATE(COUNT('Table'[Action_Type]),'Table'[Action_Type]=15),
        "25",CALCULATE(COUNT('Table'[Action_Type]),'Table'[Action_Type]=25),
        "33",CALCULATE(COUNT('Table'[Action_Type]),'Table'[Action_Type]=33)
        ),
    "CountSet",MIN(MIN([15],[25]),[33])
)
RETURN
SUMX(Dates,[CountSet])

it counts the occurences of the elements of the set per date

then picks the minimum of the count for each date
then sums up the the count numbers



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Stachu, thanks a lot! That is excatly I need!

Anonymous
Not applicable

Hi, 

 

A first option would be to create a table with the date and a count of the Action Type. Then you can create a measure checking how many Action Type counts are 3.

 

Ioana

avramioana, thank you!

I had been going this way before recieved a message from Stacu which I've marked as sulution.

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.