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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
AllanBerces
Post Prodigy
Post Prodigy

Filter and Count

Hi can someone help me on my measure. I want to count the value on my table column day difference base from 4 criteria 

1). is lessthan 48

2). is equal to 72

3). is equal to 96

4). is greaterthan 96

 

The result should be equal to the total of this measure

Count S-08 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(COUNTROWS(FILTER('Table', MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index])))))
AllanBerces_1-1776228288334.png

 

Desired Output
AllanBerces_0-1776228211377.png
S-08Day Difference S-08 -S-09/10
1/6/20260
1/23/202672
1/21/2026144
1/20/2026144
1/20/2026144
1/20/2026192
1/13/202624
1/15/20260
1/28/20260
1/26/202648
1/26/202648
1/21/202648
1/26/202648
1/14/202648
1/20/202648
1/23/202696
1/29/202696
1/5/202696
1/16/2026264
1/29/2026144
1/23/202696
1/5/2026384
1/14/2026144
2 ACCEPTED SOLUTIONS
grazitti_sapna
Super User
Super User

Hi @AllanBerces,

 

You can achieve it by creating a calculated column first to define buckets and then create all the measures separately for each bucket and for count. also create a month column.

 

I've created a sample for you, Please take a look.

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

View solution in original post

Ritaf1983
Super User
Super User

Hi @AllanBerces 

You can do it, but the bucket logic needs to be fixed first.

The four conditions you listed do not cover all possible values, so they will not add up to your total measure. In your sample data, for example, there are several rows with a value of 48, and those are not included in any of your current buckets.

Right now your groups are:

less than 48
equal to 72
equal to 96
greater than 96

That leaves out values such as 48, and also anything between 49–71 or 73–95 if those exist in the data.

If you want the sum of all category measures to match your total, each row must belong to one and only one bucket.

For example, you could create measures like these:

Count S-08 < 48 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] < 48
)
)
)
Count S-08 = 48 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] = 48
)
)
)
Count S-08 = 72 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] = 72
)
)
)
Count S-08 = 96 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] = 96
)
)
)
Count S-08 > 96 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] > 96
)
)
)

A cleaner approach would be to create a bucket column first, then use that bucket in the visual instead of creating many separate measures.

Example:

S-08 Bucket =
SWITCH(
TRUE(),
'Table'[Day Difference S-08 -S-09/10] < 48, "<48",
'Table'[Day Difference S-08 -S-09/10] = 48, "48",
'Table'[Day Difference S-08 -S-09/10] = 72, "72",
'Table'[Day Difference S-08 -S-09/10] = 96, "96",
'Table'[Day Difference S-08 -S-09/10] > 96, ">96",
"Other"
)

Then you can simply count rows by that bucket.

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

5 REPLIES 5
Ritaf1983
Super User
Super User

Hi @AllanBerces 

You can do it, but the bucket logic needs to be fixed first.

The four conditions you listed do not cover all possible values, so they will not add up to your total measure. In your sample data, for example, there are several rows with a value of 48, and those are not included in any of your current buckets.

Right now your groups are:

less than 48
equal to 72
equal to 96
greater than 96

That leaves out values such as 48, and also anything between 49–71 or 73–95 if those exist in the data.

If you want the sum of all category measures to match your total, each row must belong to one and only one bucket.

For example, you could create measures like these:

Count S-08 < 48 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] < 48
)
)
)
Count S-08 = 48 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] = 48
)
)
)
Count S-08 = 72 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] = 72
)
)
)
Count S-08 = 96 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] = 96
)
)
)
Count S-08 > 96 =
SUMX(
VALUES('Index Month'[Month]),
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
MONTH('Table'[S-08]) = SELECTEDVALUE('Index Month'[Month Index]) &&
'Table'[Day Difference S-08 -S-09/10] > 96
)
)
)

A cleaner approach would be to create a bucket column first, then use that bucket in the visual instead of creating many separate measures.

Example:

S-08 Bucket =
SWITCH(
TRUE(),
'Table'[Day Difference S-08 -S-09/10] < 48, "<48",
'Table'[Day Difference S-08 -S-09/10] = 48, "48",
'Table'[Day Difference S-08 -S-09/10] = 72, "72",
'Table'[Day Difference S-08 -S-09/10] = 96, "96",
'Table'[Day Difference S-08 -S-09/10] > 96, ">96",
"Other"
)

Then you can simply count rows by that bucket.

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983 just follow up question it doesnot give the correct Total, how can i correct it

AllanBerces_0-1776232602250.png

Thank you

 

Hi @Ritaf1983 @grazitti_sapna thank you very much for the reply work perfectly

@AllanBerces,

 

Kindly mark as solution if it worked for you

grazitti_sapna
Super User
Super User

Hi @AllanBerces,

 

You can achieve it by creating a calculated column first to define buckets and then create all the measures separately for each bucket and for count. also create a month column.

 

I've created a sample for you, Please take a look.

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.