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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Buckets Matrix of Days

I am trying to create a table and a matrix that shows the percentage change of an item to be in different days buckets, where the buckets are inclusive of each other:

 

Desired Outputs

DaysCount (Inclusive)
>020
>5011
>1006
>1504
>2002

This table should show the count of IDs the appear in each day bucket where Duration is greater than the bucket. Row 1 (Days >0) will contain all rows in the source table.

 

Then I want to create a matrix that shows the percantage (by count) of if IDs appear in both buckets:

Days50100150200
055%30%20%10%
50100%55%36%18%
100 100%67%33%
150  100%50%
200   100%

 

Row 1, means 55% appear in the >0 and the >50 buckets (11 / 20)

                       , 30% appear in the >0 and the >100 buckets (6 / 20)

                       , etc

 

SourceTable:

IDDURATION (DAYS)
19
29
330
432
5199
6201
71
83
939
10233
11101
12182
1376
1441
1564
1670
1770
1870
19130
2013

 

 

I have tried to create this dynamically but failed hard. My only solution so far is to create a measure for each calculation but then I can't it all to appear in 1 table and have to create a different table for each row of buckets.

e.g:  0 Count = COUNTROWS(DISTINCT(FILTER(SourceTable,SourceTable[Duration (Days)]>0)))

        50 Count = COUNTROWS(DISTINCT(FILTER(SourceTable,SourceTable[Duration (Days)]>50)))

        0 to 50 = [50 Count] / [0 Count]

 

KG_SA_0-1716296728658.png

 

 

Thanks

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

Hi, @Anonymous 

Start by creating calculated columns to calculate the rows that meet the criteria:

IsOver0 = IF(SourceTable[Duration (Days)] > 0, 1, 0)
IsOver50 = IF(SourceTable[Duration (Days)] > 50, 1, 0)
IsOver100 = IF(SourceTable[Duration (Days)] > 100, 1, 0)
IsOver150 = IF(SourceTable[Duration (Days)] > 150, 1, 0)
IsOver200 = IF(SourceTable[Duration (Days)] > 200, 1, 0)

vyohuamsft_0-1716362832216.png

 

Then create a new table, enter data:

vyohuamsft_1-1716362870288.png

 

Create a new measure to count rows:

Count = 
VAR _current_Days = SELECTEDVALUE('Table'[Days])
RETURN SWITCH(_current_Days,
    0,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver0]=1)),
    50,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver50]=1)),
    100,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver100]=1)),
    150,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver150]=1)),
    200,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver200]=1))
)

vyohuamsft_2-1716362941016.png

Then create a few measures to calculate their percentages and put them into the matrix:

Total Count = COUNTROWS(SourceTable)
0 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver0] = 1)))
50 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver50] = 1)))
100 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver100] = 1)))
150 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver150] = 1)))
200 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver200] = 1)))

 

vyohuamsft_3-1716363082169.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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-yohua-msft
Community Support
Community Support

Hi, @Anonymous 

Start by creating calculated columns to calculate the rows that meet the criteria:

IsOver0 = IF(SourceTable[Duration (Days)] > 0, 1, 0)
IsOver50 = IF(SourceTable[Duration (Days)] > 50, 1, 0)
IsOver100 = IF(SourceTable[Duration (Days)] > 100, 1, 0)
IsOver150 = IF(SourceTable[Duration (Days)] > 150, 1, 0)
IsOver200 = IF(SourceTable[Duration (Days)] > 200, 1, 0)

vyohuamsft_0-1716362832216.png

 

Then create a new table, enter data:

vyohuamsft_1-1716362870288.png

 

Create a new measure to count rows:

Count = 
VAR _current_Days = SELECTEDVALUE('Table'[Days])
RETURN SWITCH(_current_Days,
    0,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver0]=1)),
    50,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver50]=1)),
    100,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver100]=1)),
    150,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver150]=1)),
    200,COUNTROWS(FILTER('SourceTable','SourceTable'[IsOver200]=1))
)

vyohuamsft_2-1716362941016.png

Then create a few measures to calculate their percentages and put them into the matrix:

Total Count = COUNTROWS(SourceTable)
0 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver0] = 1)))
50 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver50] = 1)))
100 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver100] = 1)))
150 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver150] = 1)))
200 = DIVIDE([Count], CALCULATE([Total Count], FILTER(SourceTable, SourceTable[IsOver200] = 1)))

 

vyohuamsft_3-1716363082169.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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 so much, everything works well! 

 

The only thing I had to change was the: 'SourceTable'[Count]>=4,BLANK() where I made it more dynamic to blank rather than based on the hard coded 4

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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