cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
weinerheineken
Frequent Visitor

Create a Quantity On Hand measure

I'd like to create a measure that computes the stock on hand. But the sum of the stock has meaning only per day. For any selected range of dates, it should only take the sum of the values in the last date in context.

I mean if I select a date, let's say 2023-01-22, I should get the stock for this particular day. But if I select a range like 2022-01-01 to 2022-12-31, it should return the sum of the values only for the last date which is in this case 2022-12-31.

 

I have two tables:

- Inventory: Warehouse ID, Product ID, Quantity On Hand, Date Key ( format YYYYMMDD)

- Dates: Date Key ( format YYYYMMDD ), Date ( date format)

 

The two tables are linked by the Date Key column.

 

I really need help, please.

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @weinerheineken 

 

try like
stock on hand =
VAR _date = MAX(Dates[Date Key])
RETURN
CALCULATE(
    SUM(Inventory[Quantity On Hand]),
    Dates[Date Key] = _date
)

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @weinerheineken 

 

try like
stock on hand =
VAR _date = MAX(Dates[Date Key])
RETURN
CALCULATE(
    SUM(Inventory[Quantity On Hand]),
    Dates[Date Key] = _date
)

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors