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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

Count the number of parts from yesterday

Good afternoon

I hope you can help me. I think it's simple, but I don't see how to get the data! I tell you: I have 2 tables: a Calendar table (created by me) and a 'parts' table. Both are related through Calendar Date and 'parts'[Created_at]. I want to know the number of parts that were opened yesterday and in the last 15 days. To do this, I open a CALCULATE and ask you to tell me the id's of the parts, and to filter by dates with a DATESINPERIOD. The formulas for calculating the parts of yesterday and the last 15 days are as follows:

Partes_Opened_Yesterday =
CALCULATE(COUNT(parts[id]),
DATESINPERIOD(calendar[Date], MAX(calendar[Date]), -1, DAY))
Partes_Opened_Last_15days =
CALCULATE(COUNT(parts[id]),
DATESINPERIOD(calendar[Date], MAX(calendar[Date]), -15, DAY))

What's wrong? I just don't see it... It must be something very absurd, but I do not know how to see it. I would greatly appreciate it if you could help me. Thank you very much!

4 REPLIES 4
olgad
Super User
Super User

@Syndicate_Admin Have you solved your problem? If so, could you please share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime
alxdean
Advocate V
Advocate V

Two things to consider here:

1) DatesInPeriod and Datesbetween work best when used in a Filter statement. This is because the Calculate will force a hidden ALL on the context before evaluating the criteria. Try adding a FILTER('calendar', Datesbetween(a, b)) to your calculate instead. 

2) using max(Calendar[date]) is always going to be context sensitive. So if a visual is showing May 22, then the date will be 31.05 and not today. keep that in mind. if you want to make sure you work back from Today, then use TODAY(). 

olgad
Super User
Super User

Hi, 
what is the last day in your calendar? may be you dont have today as the last day but it goes till the end of the year or something which results in blanks?


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

First of all, thank you very much for your time. Very grateful! The last day on my calendar corresponds to today's date, that's correct. And there are no blanks either, neither in the data, nor in the dates...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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