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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pmc0861
New Member

DAX measure for calculating open values between two dates - Power Pivot

Hi,

 

New to Power Pivot and DAX so please excuse if this isn't the correct place to post or my question is utterly ridiculous.

 

I have a table that has a list of purchase orders. The table includes two date columns, one for the date the PO was opened and the other for the date the PO was closed.

pmc0861_0-1671502870632.png

 

I also have a dimension table that lists months

 

pmc0861_1-1671502918143.png

 

What I'm wanting to do is create a pivot table using power pivot that shows the open value of purchase orders at a point in time determined by the mth and lists the open values as follows (open value is sum of Amount where open_date <= Month & close_date > Month):

 

pmc0861_2-1671503044727.png

I'm unsure how to define this in a measure in Power Pivot as I'm not sure how to link it to the month table. I've tried a few things and even just trying something simple like only using one date I can't work out... 

 

pmc0861_4-1671503295774.png

 

Ideally I'd like a measure that looks at both dates or if recommend a better way to be looking at this.

 

Any help would be appreciated as again, I'm very new to this.

 

thanks!

1 ACCEPTED SOLUTION

OK.... scratch the above. I had a relationship set with the date table that I've now marked as inactive and its giving me what I expected.

View solution in original post

3 REPLIES 3
pmc0861
New Member

Thanks. This definitely got me moving in the right direction (stepping through this one part at a time).... I've got my DAX expression now as:

 

CALCULATE(SUMX(FILTER(PO_Committed,PO_Committed[AddedMth]<=max(Month_Tbl[Month])),[OrigCost])

)

 

Note that column names are a little different from my original post as original post was simplified to clarify the issue I was having.

 

For some reason, the above DAX only gives me items added in that month rather than in that month or earlier despite using <= in the filter. Any idea why this would be happening?

OK.... scratch the above. I had a relationship set with the date table that I've now marked as inactive and its giving me what I expected.

amitchandak
Super User
Super User

@pmc0861 , seems similar to the HR use case - https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Power BI HR Active Employee Tenure Bucketing, and Hired, Terminated, and Active employees: https://youtu.be/fvgcx8QLqZU

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors