Reply
bcarroll
Frequent Visitor
Partially syndicated - Outbound

Date bin intervals cutting off last bin

 

My objective is to build a time series chart that shows the number of errors by week.  I have a data set that includes a "Date Detected" field that has been identified as date field and has the typical year/month/day hierarchy developed within PowerBI Desktop.  To build the chart, I grouped based on the date detected.  I used a bin type of "size of bins" and set the bin size to 7 days.  Below is a screenshot of what I did....

 

bcarroll_0-1668543390496.png

And the results look like this.....

 

bcarroll_1-1668543436645.png

 

The problem is this.....   Whenever I refresh the data, it short changes the final bin which creates the impression that the defect volume just decreased significantly.  All of the bins but the last bin are 7 days.  The last bin is the remainder, so sometimes it is 1 day, sometimes 2 days, etc.  As an experiment, I put a time slicer on this... and it almost always short changes the last bin no matter what I set up as the start and end date.

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Syndicated - Outbound

Hi, @bcarroll ;

So All you don't want to show the last date group that doesn't meet 7 days, right? If so, you can create such a measure.

Flag= 
 VAR _NUM=WEEKNUM(MAX( [Date])- WEEKDAY(CALCULATE(MIN([Date]),ALLSELECTED('Table')),2),1)
 VAR _MAX=WEEKNUM(CALCULATE(MAX( [Date]),ALLSELECTED('Table'))- WEEKDAY(CALCULATE(MIN([Date]),ALLSELECTED('Table')),2),1)
 RETURN IF(CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER(ALLSELECTED('Table'),WEEKNUM([Date]-WEEKDAY(MIN('Table'[Date]),2),1)=_MAX))=7,1,IF(_MAX<>_NUM,1))

Then apply it into filter.

vyalanwumsft_0-1668564987397.png

Or

flag2 = 
var _max=WEEKNUM(CALCULATE(MAX('Table'[Date]),ALLSELECTED('Table')),1)
return 
IF(
CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER(ALLSELECTED('Table'),WEEKNUM([Date],1)=_max))<7,1,
IF(WEEKNUM(MAX('Table'[Date]),1)<>_max,1))

If not right, can you share what you want to output?


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

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Syndicated - Outbound

Hi, @bcarroll ;

So All you don't want to show the last date group that doesn't meet 7 days, right? If so, you can create such a measure.

Flag= 
 VAR _NUM=WEEKNUM(MAX( [Date])- WEEKDAY(CALCULATE(MIN([Date]),ALLSELECTED('Table')),2),1)
 VAR _MAX=WEEKNUM(CALCULATE(MAX( [Date]),ALLSELECTED('Table'))- WEEKDAY(CALCULATE(MIN([Date]),ALLSELECTED('Table')),2),1)
 RETURN IF(CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER(ALLSELECTED('Table'),WEEKNUM([Date]-WEEKDAY(MIN('Table'[Date]),2),1)=_MAX))=7,1,IF(_MAX<>_NUM,1))

Then apply it into filter.

vyalanwumsft_0-1668564987397.png

Or

flag2 = 
var _max=WEEKNUM(CALCULATE(MAX('Table'[Date]),ALLSELECTED('Table')),1)
return 
IF(
CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER(ALLSELECTED('Table'),WEEKNUM([Date],1)=_max))<7,1,
IF(WEEKNUM(MAX('Table'[Date]),1)<>_max,1))

If not right, can you share what you want to output?


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

Syndicated - Outbound

The first measure led to the desired behavior.  Thanks!

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)