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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
bwiddoes
Regular Visitor

Applying a Total to Rows where the Date is Equal to or Greater than This Month

I have a dataset that are joined to a DATE dimension.  The Datasets are:

SalesReps > SalesRepDetail (on pk_slsID = fk_slsID) 

DateDIM > SalesRepDetail (on thedate = invoicedate)

DateDIM > MonthDim on (FirstofMonth = FirstofMonth)

 

In my SalesRep Table, I have a SalesRep.daily_goal value that I multiply by MonthDim.NumofBillDays.

This gives me a Monthly Quota which works excellently.  I get actual sales through my SalesRepDetail table per MM and that works great.

 

I then have two datasets where I have no date value I want to be associated with the DateDim datasets

Opportunity - Here I take the EstRevenue of all open opportunities closing this year, divide by 12 to get a MM addition, and group by SlsID.

MedianGP - Here I take the last four months of sales totaled per month and grouped them by SlsID to get a Median_Revenue addition to apply per Month to future months

 

I can join all these together by SlsID, the issue is, I only want to apply the EstRevenue and Median_Revenue to the Current Month and then any future month.  Because they are not joined to the DateDim, they get applied to all rows when grouped by SlsID and FirstofMonth.

 

My Opportunities table has a date value, but if I join it to the DateDim dataset, it SUMs the EstRevenue per Month and not over the course of a year, and so now I have uneven amounts applied to each grouped row.  If you can imagine, it looks like this before the datedim join (red = bad, green = good).

ID = 1, Quota = 20K, Actual = 25K, EstRev = 10K, Median = 23K, MM1 (because I don't want the summaries applied to past months)

ID = 1, Quota = 21K, Actual = 16K, EstRev = 10K, Median = 23K, MM2

ID = 1, Quota = 19K, Actual = 0, EstRev = 10K, Median = 23K, MM3

 

Ideally, assuming the current MM = 2 I would want it to look like this:

ID = 1, Quota = 20K, Actual = 25K, EstRev = 0, Median = 0, MM1

ID = 1, Quota = 21K, Actual = 16K, EstRev = 10K, Median = 23K, MM2

ID = 1, Quota = 19K, Actual = 0, EstRev = 10K, Median = 23K, MM3

 

When I join to the DateDim it looks like the following which is undesirable:

ID = 1, Quota = 20K, Actual = 25K, EstRev = 3K, Median = 23K, MM1

ID = 1, Quota = 21K, Actual = 16K, EstRev = 5K, Median = 23K, MM2

ID = 1, Quota = 19K, Actual = 0, EstRev = 18K, Median = 23K, MM3

 

In summary, I can't figure out how to keep my EstRevenue and Medians getting applied to Historical months, and when I try to apply a datedim join, it breaks them down per MM and does not evenly apply my totals to each month, current and future.

 

If I can apply any more detail I am happy to.  We are trying to determine if our slsreps have enough in their CRM pipelines to help them meet their future monthly quotas, and, show them their historical median GP$ they do per month and have it sit as a base for what they may do per future month without the EstRevenue they might get from open opportunities.

 

Also note I cannot bring in my Opportunity data into SQL and we are connecting to it through dataverse in PowerBI.  Otherwise, I would transform that data in SQL before I brought it in to powerBI.  Any help is much appreciated. 

1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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