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
prakritnepal
Helper I
Helper I

Add a column value based on most recent date and ID

Hi, 

 

I am trying to create a dynamic snapshot of our Pipeline from salesforce. THis would enable us to see what the pipeline was 3 months ago or a year ago and filter it our accordingly. The process I am trying to follow is:

 

 

Opportunity IDAmountLast modified dateStage
1234abc50008/15/201890
1234abc50006/15/201880
1234abc50005/15/201870
1234abc30004/15/201860
5678cde150007/29/201890
5678cde150007/15/201880
5678cde150007/8/201870
5678cde120006/25/201860
5678cde120006/20/201830

 

 

 

Have a slicer determine the latest date. So lets say the date we chose is 6/20/18, the total amount in pipeline would be 17,000(12,000+5,000). If we chose 4/30/18, the amount would be 3000. 

 

 

I am not sure how I can select the most recent date < max date among selected dates by unique opportunity ID and sum one value per opportunity ID

 

 

Any help would be appreciated. 

 

Thanks. 

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @prakritnepal,

 

I made one sample for your reference. Please refer to the steps as below.

 

1. Enter the data you shared and inset an index column that sort by date in power query.

 

2. Create a dimtime table.

Dimtime = CALENDARAUTO()

3. create the measure as below the get thre result as we excepted.

 

cal =
VAR inde =
    CALCULATE (
        MAX ( Table1[Index] ),
        FILTER (
            Table1,
            Table1[Last modified date] <= SELECTEDVALUE ( Dimtime[Date] )
                && Table1[Last modified date] <= SELECTEDVALUE ( Dimtime[Date] )
        )
    )
RETURN
    CALCULATE (
        SUM ( Table1[Amount] ),
        FILTER ( Table1, Table1[Index] <= inde && Table1[Index] >= inde - 1 )
    )

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thank you for this example but you have created a measure to filter per opportunity ID to extract a value individually. I cannot do that because there are hundreds of thousands of opportunity IDs in salesforce. 

 

The logic I think that works but I am not being able to create in BI is:

 

For each [opportunity ID],       ' we cannot define opportunity ID as they are dynamic and there are new entries every day

select max(last modified date) 'this date needs to be <= a given date

sum(Amount), filter(as per selected date)

 

 

We need some sort of a loop in opportunity ID to extract only one date and one amount per ID with date having an additional clause. 

 

I am also getting incorrect values on certain dates. when I select 8/5/18, cal is 30K. This is not correct as per the data set. 

 

 

 

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Kudoed Authors