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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
arpost
Advocate V
Advocate V

How do you write a measure to calculate totals based on an "active" percentage value?

Greetings, PBI community! I am needing to calculate totals based on a percentage that was "active" during the specified date range and am struggling to figure out the scenario. Figure it'd be easier for me to "show" rather than just tell, so here goes.

 

I have a table containing data as follows:

Sales

DateValue
1/1/2014$100
2/1/2014$500
7/1/2014$600
5/1/2015$200

 

I also have a table listing the different commission % rates that were in effect at a particular date.

Commission Rates

DatePercentage
1/1/201310%
6/1/201415%
1/1/201520%

 

What I'm wanting to do is create a measure that shows the total commission $ for a given range of time based on the % rate that was in effect.

 

For example, with the sales data, this is the equivalent result in the form of a table:

DateValueCommission

Rate

1/1/2014$100$1010%
2/1/2014$500$5010%
7/1/2014$500$7515%
5/1/2015$200$10020%

 

Ultimately, I want to "roll up" the calculations for a given year, so the total for 2014 would be $135 ($10 + $50 +$75).

3 REPLIES 3
arpost
Advocate V
Advocate V

Greetings, @Ashish_Mathur  and @ryan_mayu! Thank y'all both for responding. These are great solutions, but I've hit a roadblock - the datasource is using DirectQuery, which doesn't support either MAXX or CALCULATE in calculated columns! 😞 Any ideas on how this can be accomplished solely using measures?

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ryan_mayu
Super User
Super User

@arpost 

you can create a column to calculate commission

 

commission = 
VAR _date=maxx(FILTER('Commission Rates','Commission Rates'[Date]<=Sales[Date]),'Commission Rates'[Date])
VAR _per=maxx(FILTER('Commission Rates','Commission Rates'[Date]=_date),'Commission Rates'[Percentage])
return Sales[Value]*_per

then create a date table

1.PNG

pls see the attachment below

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.