cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
zipke Regular Visitor
Regular Visitor

COUNTX(currentgroup()) add column with filter

Hi all,

 

I have a table with different IDs linked to a specific Category. These IDs all have an Entry Date stored in a different (related) table.

 

I created an overview table from a different table with the GROUPBY() and COUNTX function.

I managed this with the code:

Categorization overview = GROUPBY(Categorisation,Categorisation[Category],"Count",COUNTX(CURRENTGROUP(),Categorisation[Category]))

This is the table: the green column is the result of the above code. This works OK.

 

count.JPG

 

The two columns in red are the columns I am trying to add.

 

Add column 1:

I need a column that only counts the IDs with an Entry Date > 01012019. How can I add this column? I tried to add an IF statement but when I do this I get a rondom number that is the same for each row.

 

Add column 2:

I then also need a column with the percentage of this column 1 to the initial column which contains all IDs. I want to show how much percent of the total IDs in that category has recently been created (based on the Entry Date).

 

Thanks for your help!

 

Zipke

1 ACCEPTED SOLUTION

Accepted Solutions
zipke Regular Visitor
Regular Visitor

Re: COUNTX(currentgroup()) add column with filter

Hi @v-lili6-msft ,

 

It is not that easy to share my relationships because it is a larger complex file. But in manged to solve the problem in the meantime! I used a different code and it works!

I created the table with only the categories and then added a Count column and a Count column for the IDs.

Table creation:

Categorisation overview = GROUPBY(Categorisation,Categorisation[Category])

Count of IDs per category:

Count = CALCULATE(
    COUNTROWS(Categorisation),
        FILTER(Categorisation,Categorisation[Category]=EARLIER([Category])
        )
)

Column 1:

New IDs count = CALCULATE(
    COUNTROWS(Categorisation),
        FILTER(Categorisation,Categorisation[Category]=EARLIER([Category])),
        FILTER(RELATEDTABLE('Entry Dates'),'Entry Dates'[Entry date]>=20181201)
        )

Thanks for your help though!

 

Regards,

Zipke

5 REPLIES 5
Community Support Team
Community Support Team

Re: COUNTX(currentgroup()) add column with filter

hi, @zipke 

You may try this simple way:

Step1:

Create the relationship between Categorisation table and new overview table by category column.

Step2:

Then use this formula to add new column

Column 1 = CALCULATE(COUNTA('different (related) table'[ID]),FILTER(RELATEDTABLE('different (related) table'),'different (related) table'[Entry Date]>DATE(2019,1,12)))
Column 2 = 'Categorization overview'[Column 1]/'Categorization overview'[Count]

 

Best Regards,

Lin

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

Re: COUNTX(currentgroup()) add column with filter

Hi @v-lili6-msft ,

 

Thanks for your response. For column 1, I do get a count, but it shows me the total on each row. It does not split up the value per category. I did create the relationship between the Categorisation table and the Entry Date table.

 

How should I tweek the code?

 

Thanks in advance

Community Support Team
Community Support Team

Re: COUNTX(currentgroup()) add column with filter

hi, @zipke 

Could you share your sample pbix file or screenshots about the relationship?

 

Best Regards,

Lin 

 

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

Re: COUNTX(currentgroup()) add column with filter

Hi @v-lili6-msft ,

 

It is not that easy to share my relationships because it is a larger complex file. But in manged to solve the problem in the meantime! I used a different code and it works!

I created the table with only the categories and then added a Count column and a Count column for the IDs.

Table creation:

Categorisation overview = GROUPBY(Categorisation,Categorisation[Category])

Count of IDs per category:

Count = CALCULATE(
    COUNTROWS(Categorisation),
        FILTER(Categorisation,Categorisation[Category]=EARLIER([Category])
        )
)

Column 1:

New IDs count = CALCULATE(
    COUNTROWS(Categorisation),
        FILTER(Categorisation,Categorisation[Category]=EARLIER([Category])),
        FILTER(RELATEDTABLE('Entry Dates'),'Entry Dates'[Entry date]>=20181201)
        )

Thanks for your help though!

 

Regards,

Zipke

Community Support Team
Community Support Team

Re: COUNTX(currentgroup()) add column with filter

hi, @zipke 

You're welcome.

It's pleasant that your problem has been solved, could you please mark the reply as Answered.  Smiley Very Happy

 

Best Regards,

Lin

 

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

Helpful resources

Announcements
Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 312 members 2,985 guests
Please welcome our newest community members: