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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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])

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])

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.