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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
TheSweeper
Helper I
Helper I

Amateur Needing Help with Calculated Measure

Can someone kindly help  me with this calculated measure?

 

I am trying to get this measure not to exclude Line 2 Charge Amount Totals.  The sum for Charge Line ID 8264 should be $576.  My measure doesn't take into account some Charges may be on Line 2, 3, etc. 

 

Here is my current measure. Thank you in advance!!!!!

Measure.png

IsLatest =
VAR charge_id = Charges[Charge ID]
VAR latest_charge_id_date =
CALCULATE(
MAX(Charges[Charge Last Modified Date]),
ALL(Charges),
Charges[Charge ID] = charge_id
)

RETURN
IF(
Charges[Charge Last Modified Date] = latest_charge_id_date,
TRUE(),
FALSE()
)
Total ChargeMRNCharge IDCharge Line IDAcct DateCPTLast Modified DateLine NumberIs Latest
5763930806382644/1/22Q99674/1/222

False

5763930806382644/1/22Q99674/5/222

False

5763930806382644/1/22Q99674/20/222

False

956.723930806482654/1/22767004/1/221

False

956.723930806482654/1/22767004/5/221

False

956.723930806482654/1/22767004/20/221

True

 

Example Report.png

1 ACCEPTED SOLUTION

@TheSweeper , Try a measure like

 

Measure =
VAR __id = MAX ('Table'[Charge Line ID] )
VAR __date = CALCULATE ( MAX('Table'[Charge Last Modified Date] ), ALLSELECTED ('Table' ), 'Table'[Charge Line ID] = __id )
return
CALCULATE ( Sum ('Table'[Total Charge] ), VALUES ('Table'[Charge Line ID] ),'Table'[Charge Line ID] = __id,'Table'[Charge Last Modified Date] = __date )

View solution in original post

7 REPLIES 7
TheSweeper
Helper I
Helper I

Woohooo I figured it out

 

@amitchandak Thank you so much for your help!

 

I  used this formula to return the correct total. 

 

SUMX(SUMMARIZE(Charges, Charges[Charge Line ID], "Last Mod Charge", [Measure]), [Last Mod Charge])
TheSweeper
Helper I
Helper I

@DataInsights 

 

If you have time do you mind taking a stab at this? Unfortunately I can't continue building my report without this formula being completely correct in its output.  😞 

@DataInsights - I figured it out 🙂

PezzPower
New Member

Also an amateur, but does using filter within the CALC help you here? 

https://community.powerbi.com/t5/Desktop/DAX-Calculate-the-Max-for-a-Group/td-p/64645 

I tried but it didn't work. Thank you though!

 

@TheSweeper , Try a measure like

 

Measure =
VAR __id = MAX ('Table'[Charge Line ID] )
VAR __date = CALCULATE ( MAX('Table'[Charge Last Modified Date] ), ALLSELECTED ('Table' ), 'Table'[Charge Line ID] = __id )
return
CALCULATE ( Sum ('Table'[Total Charge] ), VALUES ('Table'[Charge Line ID] ),'Table'[Charge Line ID] = __id,'Table'[Charge Last Modified Date] = __date )

@amitchandak 

 

Your measure now gives me the correct data just the incorrect total. Truly appreciate your help!!!

 

Any suggestions on how I can show the correct total? 576+956.72+1,6803.96 = $3,213.68

I added the new measure below the screenshot. 

Correct Measure_Need Correct Total.png

Measure =
VAR __id = MAX ('Charges'[Charge Line ID])
VAR __date = CALCULATE ( MAX('Charges'[Charge Last Modified Date] ), ALLSELECTED ('Charges' ), 'Charges'[Charge Line ID] = __id )
return
CALCULATE ( Sum ('Charges'[Total Charge] ), VALUES ('Charges'[Charge Line ID] ),'Charges'[Charge Line ID] = __id,'Charges'[Charge Last Modified Date] = __date )
 
Again, truly appreciate your help!
Sincerely,
Amanda Cross

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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