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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
TKezic
New Member

Problem with totals in matrix_Need help with Dax

Hi, 

I have made the following measure:

Ultimo kostværdi lager =

VAR UltimoOprindkoebtlager = CALCULATE([Ultimo lagerantal])

VAR OprKostprisPrEnhed = CALCULATE(MIN('Value Entry'[Oprindelig kostpris pr. enhed]),ALL('Date'))

VAR TotalOprKostpris = CALCULATE(OprKostprisPrEnhed*UltimoOprindkoebtlager)

 VAR OprindeligKostvaerdi =
  CALCULATE(TotalOprKostpris,
    DATESBETWEEN (
        'Date'[Date],
        BLANK (),
        LASTDATE ( 'Date'[Date] )
    ))

VAR Indkoebsvaerdi =
 CALCULATE(SUM('Value Entry'[Cost Amount (Actual)]), 'Value Entry'[Item Ledger Entry Type] = "Purchase", 'Value Entry'[Document Type] = "Purchase Invoice",
  DATESBETWEEN (
        'Date'[Date],
        BLANK (),
        LASTDATE ( 'Date'[Date] )
    ))
     
     +  CALCULATE(SUM('Value Entry'[Cost Amount (Expected)]), 'Value Entry'[Item Ledger Entry Type]= "Purchase",
     DATESBETWEEN (
        'Date'[Date],
        BLANK (),
        LASTDATE ( 'Date'[Date] )
    ))

VAR Ultimoindkoebtlager = CALCULATE([Ultimo lagerantal], 'Value Entry'[Document Type] = "Purchase Receipt")

VAR BCKostVaerdi = DIVIDE(Indkoebsvaerdi,Ultimoindkoebtlager)*CALCULATE([Ultimo lagerantal])

Return
if (OprKostprisPrEnhed>0,OprindeligKostvaerdi,BCKostVaerdi)
 
Can anybody give me a hint on how to create this measure, so that the total in a matrix shows the correct number?
1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely.
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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.