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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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