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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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