Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
SriRed123
Regular Visitor

Summarise and count data if available on all days in Slicer date range

HI,

I am new to power BI and need help with below query.

I have a table with below data. The result should summarize the Data at product and get the count of distinct locations if the location present on all days selected in the slicer data range.

For Date range 1-DEC-19 to 1-DEC-19 result should be

A   3

B  3

For Date range 30-Nov-19 to 1-DEC-19:

A    2

B    1

For Date range 29-Nov-19 to 1-DEC-19:

A    1

B    0

Product

Location

Date

A

1

1-Dec-19

A

1

30-Nov-19

A

2

1-Dec-19

A

2

30-Nov-19

A

2

29-Nov-19

A

3

1-Dec-19

B

1

1-Dec-19

B

1

30-Nov-19

B

2

1-Dec-19

B

2

29-Nov-19

B

2

28-Nov-19

B

3

1-Dec-19

 

Sql query for producing similar result

SELECT Product, count(distinct Location) FROM (

SELECT Product,Location,count(*) cnt FROM #temp

WHERE Date between <SlicerStartDate> and <SlicerEndDate>

GROUP BY Product,Location

Having count(*) = (SELECT Datediff(Day,MAX(<SlicerEndDate>), MIN(<SlicerStartDate>)) + 1)) A

GROUP BY A.Product

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Probably something along the lines of:

 

Measure = 
VAR __count = COUNTX(DISTINCT('Table'[Date]),[Date])
VAR __table = SUMMARIZE('Table','Table'[Location],"Rows",COUNTROWS('Table'))
VAR __table1 = FILTER(__table,[Rows] = __count)
RETURN
COUNTX(__table1,[Location])

See attached.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

Probably something along the lines of:

 

Measure = 
VAR __count = COUNTX(DISTINCT('Table'[Date]),[Date])
VAR __table = SUMMARIZE('Table','Table'[Location],"Rows",COUNTROWS('Table'))
VAR __table1 = FILTER(__table,[Rows] = __count)
RETURN
COUNTX(__table1,[Location])

See attached.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Many thanks. The measure is working exactly as per my requirement.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors