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
MojoGene
Post Patron
Post Patron

Aggregating or Merging two rows of data

I am trying to write a measure that will aggregate two separate rows of data for analysis or alternatively merge the rows together.

 

My data look like this:

Screenshot 2017-12-31 21.21.10.jpg

 

Briefly, during the process of billing, hours and fees are "relieved," i.e., moved from WIP to accounts receivable. When the bill is paid, usually at a later date, the FeeAmtPaid is entered in a separate row under the same billing number, which removes that amount from accounts receivable. Hence, whenever there is a payment there will be at least two rows under the same bill number. (If the bill is paid in multiple increments, there can be >2 rows for the same bill number.)

 

Is it possible to write a measure that aggregates the "relieved" row and the "paid" row(s) together in order to calculate FeeAmtPaid in 2017 no matter when the fees and hours were relieved? Alternatively, it there a way to merge the two rows together? (I am no "M Code" expert unfortunately.)

 

 

 

1 ACCEPTED SOLUTION

Ooops. Forgot the last measure to get only the 2017 aggregate paid fees per hour:

2017 FeesPerPaidHourAggregate =
CALCULATE (
    [FeesPerPaidHourAggregate],
    FILTER ( Table, [Date Paid Year] = 2017 )
)

View solution in original post

3 REPLIES 3
MojoGene
Post Patron
Post Patron

I should have added that I would like to take the FeeAmtPaid in the current year and divide it by the HoursRelieved in order to arrive at an effective (paid) billing rate per hour. This is why I need the HoursRelieve and the FeeAmtPaid on the same row.

 

Thanks.

I appear to have found a workable solution by brute force of trial and error.

 

This measure aggregates the FeeAmtPaid on the different rows:

 

FeeAmtPaidAggregate =
CALCULATE (
SUM ( Table[FeeAmtPaid] ),
ALLEXCEPT ( Table, Table[BillNumber] )
)

This measure aggregates the HoursRelieved on the different rows:

HoursRelievedAggregate =
CALCULATE (
	SUM ( Table[HoursRelieved] ),
	ALLEXCEPT ( Table, Table[BillNumber] )
)

This calculates the effective billing rate in 2017:

FeesPerPaidHourAggregate =
DIVIDE ( [FeesPaidAggregate], [HoursRelievedAggregate] )

I would be interested in any critique of this approach.

Ooops. Forgot the last measure to get only the 2017 aggregate paid fees per hour:

2017 FeesPerPaidHourAggregate =
CALCULATE (
    [FeesPerPaidHourAggregate],
    FILTER ( Table, [Date Paid Year] = 2017 )
)

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.