DAX : Occurrences of "count"

0 votes

So I have a table;

Now, I want to apply some dax instructions to that table, and display this data in a chart. In other words,  if it is the first time that the Country's name appears, it must show 1 and 2 for the second time.

Can anybody help me? Thanks.

Nov 21, 2018 in Power BI by Shubham
• 13,380 points
1,910 views

1 answer to this question.

0 votes

Try this for creating a calculated column called Occurrences:

Occurrences =
CALCULATE (
    COUNT ( [Pais] ),
    FILTER (
        'Table',
        [Index] <= EARLIER ( 'Table'[Index] )
            && [Pais] = EARLIER ( 'Table'[Pais] )
    )
)

Index must be an incremental key in each row.

Let me know if this helps.

answered Nov 21, 2018 by Upasana
• 8,590 points
Hi,

This dax is taking too much time. I  tried on a data which has 5lakhs+ rows and the dax is showing 'working on it' for like half an hour.
Can you please help with some other similar dax function.

Hi, @Sandeep,

The COUNTROWS function counts the number of rows in the specified table, or in a table defined by an expression.

Syntax: COUNTROWS(<table>)

This function can be used to count the number of rows in a base table, but more often is used to count the number of rows that result from filtering a table, or applying context to a table.

Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0. Microsoft Excel also returns zero if no rows are found that meet the conditions.

=COUNTROWS('Orders')

I hope this explanation will help.

Related Questions In Power BI

0 votes
1 answer

Count occurrences in DAX

You can use DAX functions to do ...READ MORE

answered Mar 9, 2019 in Power BI by avantika
• 1,500 points
8,435 views
0 votes
1 answer

Max count of workspaces per one PRO user

Right now, it is 250, will be ...READ MORE

answered Sep 24, 2018 in Power BI by Hannah
• 18,070 points
82 views
0 votes
1 answer

Calculating MoM Variance of a Measure Field using DAX

Create an intermediate calculated column that considers ...READ MORE

answered Feb 28, 2019 in Power BI by Shubham
• 13,380 points
3,454 views
0 votes
1 answer

Add Column Count_of_people across two tables to get the count of people from a city.

Hi Anitha, 1. Merge both tables, using City ...READ MORE

answered Mar 22, 2019 in Power BI by Cherukuri
• 32,460 points
82 views
+3 votes
2 answers

Combine tables in Power BI

You can also achieve this using a ...READ MORE

answered Oct 5, 2018 in Power BI by lina
• 8,200 points

edited Oct 11, 2018 by Kalgi 565 views
0 votes
1 answer

Power Bi Dax Table

You need to wrap the numbers in ...READ MORE

answered Oct 5, 2018 in Power BI by Kalgi
• 51,890 points
233 views
0 votes
2 answers

Power BI Dax Multiple IF AND Statements

HI I have Column Patient 12 13 14 15 18 IN Patient=12, 13 Out ...READ MORE

answered May 22, 2019 in Power BI by VNK
14,463 views
0 votes
1 answer

Distinct count filtered by condition using Power BI Dax

Try this, it should work: DistinctCountActiveMonths = CALCULATE( ...READ MORE

answered Oct 5, 2018 in Power BI by Kalgi
• 51,890 points
20,903 views
0 votes
1 answer

Dax: Sum of values from many columns in a row

Yes, you can. Try to "Unpivot other columns" ...READ MORE

answered Apr 3, 2019 in Power BI by Upasana
• 8,590 points
2,817 views
0 votes
1 answer

Calculate Time Intersection to Correlate Sequences of Independent Events

I think this solution requires a CROSS JOIN implementation. ...READ MORE

answered Oct 26, 2018 in Power BI by Upasana
• 8,590 points
117 views