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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Namarcil
Regular Visitor

Track Inventory value

Hello everyone, 

 

i'm in fight for many hours now to get a solution to my problem 

 

I have this Dax formula to compute a cumulated addition to get a daily stock snapshot.

 

the formula here 

Images de stock = CALCULATE(SUMX('LIGNES',LIGNES[Quantités pour stock]),'Calendrier'[Date]<=max('Calendrier'[Date]))

Where 

LIGNES[Quantités pour stock]

is a column I have created in my Table "LIGNES" which is the fact table regrouping all Types of movement and all transactions.

 

It works pretty well. and provide the expected results

Namarcil_0-1709634059375.png

However we can notice that my prices changed quite often during the holding item period , it works well on both tables

Namarcil_1-1709634133722.png

 

The problem is that the last dated Purchasing price ([Historique PA statique])  need to be multiplied by the Stock Snapshot   and by the last purchasing price.

 

Now I would like to get the Stock Value,

 

Images de stock = CALCULATE(SUMX('LIGNES',LIGNES[Quantités pour stock]),'Calendrier'[Date]<=max('Calendrier'[Date]))
Historique PA Statique =
IF(
    HASONEVALUE(LIGNES[ARTICLE_KEY]),
    CALCULATE(
        SUMX(
            LIGNES,
            LIGNES[Dernier prix achat ligne]
        ),
        LIGNES[Libelle nature de mouvement] = "Facture fournisseur"
        ALL(LIGNES[ARTICLE_KEY])
    ),
    BLANK()

)

 Which finaly make 

Stock value = [Images de stock]*[Historique PA Statique] 

= something like this 

Namarcil_3-1709634714112.png

 

How can i achieve this since [Dernier prix d'achat] (the column in the table "LIGNES")  must be taken only on LIGNES'[Libelle nature fournisseur] = "Facture fournisseur" and only based on one quantity 

 

like this table 

 

Namarcil_4-1709634830214.png

 

 🙂 

 

Thank you in advance for any help !

 

2 REPLIES 2
danextian
Super User
Super User

Hi @Namarcil ,

 

Please post a workable sample data, not an image/s.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hello,

my model is really heavy

and i don't know exactly how i can show you , maybe with a picture of my model?

 

if it can help, Here i only need two tables , LIGNES (Fact table) and Calendrier (Calendar) 

 

Linked together on LIGNES'[Date ligne] and Calendrier[Date]

 

in tbale "LIGNES" i have created this column 

 

Quantités pour stock =

        VAR QuantiteAjustee = SWITCH (
            'LIGNES'[Libelle nature de mouvement],
            "Sorties exceptionnelles", - ABS('LIGNES'[Quantités mouv stock]),
            "Transfert émis", - ABS('LIGNES'[Quantités mouv stock]),
            "Ticket", IF('LIGNES'[Quantités mouv stock] > 0, - ABS('LIGNES'[Quantités mouv stock]), ABS('LIGNES'[Quantités mouv stock])),
            "Réservations clients", IF('LIGNES'[Quantités mouv stock] > 0, - ABS('LIGNES'[Quantités mouv stock]), ABS('LIGNES'[Quantités mouv stock])),
            'LIGNES'[Quantités mouv stock]
        )
        RETURN IF(QuantiteAjustee < 0 && 'LIGNES'[Prix unitaire HT net ligne] < 0, ABS(QuantiteAjustee), QuantiteAjustee)

Which represents The Quantities on lines which affect the stock levels.

 

Namarcil_0-1709643319711.png

 

i have created this cumalated stock levels measure 

 

Images de stock = CALCULATE(SUMX('LIGNES',LIGNES[Quantités pour stock]),'Calendrier'[Date]<=max('Calendrier'[Date]))

Which provide me with the expected results (as per shows previously)

Namarcil_2-1709643527498.png

 

Which take the total quantities of each days, and repeat the value if no transaction.

 

I Can have also the last purchase price per items aggregated by days when we have price changes

Namarcil_4-1709643681205.png

So for first example my value stock should be 536 * 658.4 = 352902.4

 

With my formula 

 

Cumulative Historique PA = [Images de stock]*[Historique PA Statique 2]

i obtain 352902.4 which is correct, 

 

however i cannot repeat this informatio accross lines 

Namarcil_5-1709644164964.png

 

How can I manage this?

 

🙂 Sorry if i cannot send my file :s

 

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.