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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
char23
Helper II
Helper II

Date tally with measure

Hello, 

 

I am trying to create a visual similar to the one below. I have a date table (Table 1) that is based on min start and max finish dates from another table (Table 2). The date table has a date column, then 3 other columns that show the year, month, and date as first of month. I have another table (Table 2) that is not connected to the date table. It has multiple rows with a column for start date and a column for finish date. I want to write a measure that will output a "1" for every day between the start and finish date (but I want this to be show in the matrix by month). I also want the totals for each month to sum correctly in each column. 

 

Thank you for the help!

 

char23_0-1740529941351.png

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @char23 

It is correct that you will need to use a disconnected table (dates has no relationship with fact). Here's a sample measure:

Days in Calendar = 
SUMX ( 
    // Iterate over each date in the Dates table
    Dates, 
    
    // Count how many IDs are active on the current date
    COUNTROWS (
        FILTER ( 
            Table2, 
            // A ID is active if the start date is on or before the current date
            // AND the end date is on or after the current date
            Table2[Date Start] <= Dates[Date]
                && Table2[Date End] >= Dates[Date]
        )
    )
)

danextian_0-1740543059246.png

danextian_1-1740543114627.png

Please see the attached pbix for the details.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @char23 ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

danextian
Super User
Super User

Hi @char23 

It is correct that you will need to use a disconnected table (dates has no relationship with fact). Here's a sample measure:

Days in Calendar = 
SUMX ( 
    // Iterate over each date in the Dates table
    Dates, 
    
    // Count how many IDs are active on the current date
    COUNTROWS (
        FILTER ( 
            Table2, 
            // A ID is active if the start date is on or before the current date
            // AND the end date is on or after the current date
            Table2[Date Start] <= Dates[Date]
                && Table2[Date End] >= Dates[Date]
        )
    )
)

danextian_0-1740543059246.png

danextian_1-1740543114627.png

Please see the attached pbix for the details.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Abhilash_P
Super User
Super User

Hi @char23 ,
Can you try creating below measures

1. Create a Measure to Flag Dates Between Start and Finish
Active_Days =
VAR SelectedDate = SELECTEDVALUE('Table 1'[Date])
RETURN
SUMX(
'Table 2',
IF(
SelectedDate >= 'Table 2'[Start Date] && SelectedDate <= 'Table 2'[Finish Date],
1,
0
)
)


2. Adjust the Measure to Work at the Month Level
Active_Days_By_Month =
SUMX(
'Table 2',
CALCULATE(
COUNTROWS('Table 1'),
'Table 1'[Date] >= 'Table 2'[Start Date] &&
'Table 1'[Date] <= 'Table 2'[Finish Date]
)
)


SamanthaPuaXY
Helper II
Helper II

Hi @char23 , you could try a calculated column

NewCol = 
var maxdate = MAX('Table1'[Date])

var mindate = MIN('Table1'[Date])

Return IF('Table2'[Date] < maxdate && 'Table2'[Date] > mindate, 1, blank())

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.