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

count rows on summarize column filtered by date measure

Hi guys,

 

I am strugling to create a measure which will be be filtering by date slicer coming from a calendar table. My data are like these:

 

Codesdategroup
X00011/2/2020A
X00021/3/2020A
X00021/4/2020B
X00041/5/2020A
X00051/6/2020A
X00061/7/2020A
X00061/8/2020A
X00081/9/2020A
X00091/10/2020A
X00101/11/2020A
X00101/12/2020B
X00121/1/2021A
X00131/2/2021A
X00141/3/2021A
X00151/4/2021A
X00151/5/2021B
X00171/6/2021A
X00181/7/2021A
X00191/8/2021A
X00201/9/2021A
X00211/10/2021A
X00221/11/2021A

 

the above table is linked with a calendar table.

What I am trying to do is to find on a card how many Codes have group A and groub B but also to be able  to filter from a date slicer the dates that is looking for. 
Example if the slicer is between 01/01/2021 and 31/12/2021 the result should be 1 since between 01/01/2021 and 31/12/2021 only code "X0015" has group A and B. If the date slicer if  from 1/4/2020 then the result should be 2 ("X0010","X0015" have both groups).

I have tried the below but i can't put the date slicer:

 

Counttable =
CALCULATETABLE(
SUMMARIZECOLUMNS(
Sheet1[Codes],
"count", [count_group])) 
8 REPLIES 8
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

v-lionel-msft_0-1622106252407.png

My date format is mm/dd/yyyy, is it caused by this?

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

Yes, this cause the problem. But when I am tring to change to lacal format (D/M/YYYY) then the calculation shows wrong number.

From 1st of December 2020 until 1st of November of 2021 only one code(X0015) have both A and B group.

amitchandak
Super User
Super User

@Anonymous , Try a measure like

countx(filter(summarize(Table, Table[Codes], "_1", calculate(distinctcount(Table[group]), filter(Table, Table[group] in {"A", "B"}))), [_1] =2),[Codes])

Anonymous
Not applicable

Thank you, man, for your quick response. At least I am looking from the right side.
It is almost what I did. My formula is
countx(filter(summarize(table,table[codes], "_1", distinctcount(group)),distinctcount(group)>1,max(Calendar[Date]))
Now I have one more step, to replace the "max('Calendar'[Date])" with dates between 2 other measure dates and not from the date.

Hi @Anonymous ,

 

Try to refer to my .pbix file.

v-lionel-msft_0-1621489897850.png

 

Best regards,
Lionel Chen

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

 

Anonymous
Not applicable

Thank you @v-lionel-msft ,

 

but in your case you count the group of "A","B" in the given period. What i am looking is in a date range (which the start_date and end_date is a calculated measure of a calendar table with some extra calculations) to see how many codes have group "A" and "B". In your pbix if in the dates put from 12/1/20 until 11/1/21 the result you get is 2 instead of 1 which is the correct. 

Hi @Anonymous ,

 

v-lionel-msft_0-1621501140594.png

I don't particularly understand what you said.
My calculation logic is:
During the period from 12/1/2020 to 1/11/2021, only X0015 is counted.

 

What is the calculation logic you want to realize?

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

Thank you for your reply.

Have you changed anything? my result in your pbix is as per below (date format d/m/yyyy)

 

result.jpg

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.