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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
TEACHY888
Regular Visitor

Calculate the Start date Amount of ids within a date range

Hi , I am new on DAX and need some help here. 

I need to sum the Start Date (Min date ) Amount of IDs with in a selected date range. I have tried chatGPT and it has provided me this : 

VAR StartDate = MIN(OpportunityOldValue_NewValue[changed_date])
VAR EndDate = MAX(OpportunityOldValue_NewValue[changed_date])
RETURN
    SUMX(
        VALUES(OpportunityOldValue_NewValue[opportunity_Sid]),
        CALCULATE(
            SELECTEDVALUE(OpportunityOldValue_NewValue[old_amount]),
            FILTER(
                OpportunityOldValue_NewValue,
                OpportunityOldValue_NewValue[changed_date] = MAX(OpportunityOldValue_NewValue[changed_date]) &&
                OpportunityOldValue_NewValue[changed_date] >= StartDate &&
                OpportunityOldValue_NewValue[changed_date] <= EndDate
            ),
            OpportunityOldValue_NewValue[changed_date] = StartDate
        )
    ), the code works for individual IDs but when I want to visualse in a graph or table the Total amount is blank.
 
Would be great if someone could look into this , many thanks in advanceNo Total.PNG 
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@TEACHY888 , this happens when row context has been used.

Assume your current measure name is Pipeline start

 

create a new measure like

 

Sumx(Summarize( OpportunityOldValue_NewValue, OpportunityOldValue_NewValue[opportunityid],OpportunityOldValue_NewValue[changed_date], "_1", [pipeline start]) , [_1])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

TEACHY888
Regular Visitor

@amitchandak , Mnay thanks for your input, it works 👍

View solution in original post

2 REPLIES 2
TEACHY888
Regular Visitor

@amitchandak , Mnay thanks for your input, it works 👍

amitchandak
Super User
Super User

@TEACHY888 , this happens when row context has been used.

Assume your current measure name is Pipeline start

 

create a new measure like

 

Sumx(Summarize( OpportunityOldValue_NewValue, OpportunityOldValue_NewValue[opportunityid],OpportunityOldValue_NewValue[changed_date], "_1", [pipeline start]) , [_1])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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