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
BaronSdG
Resolver II
Resolver II

CALCULATE items from today up to 30 days before

Hello,

 

I need to count all the rows which are both Closed (this is working) and have a Closed date old at maximum of 30 days from today. This is the formula.

 

CALCULATE([Count_Rows_J],'Jira Datalake'[Status Open vs Closed items (groups)] = "Closed")

 

Can you help me? Thanks

1 ACCEPTED SOLUTION

@Greg_Deckler I have used both formulas and I was able to fix yours, which was just missing the table name after FILTER. This formula is now working.

 

_Count_Closed_30days_dynStr =
VAR created = CALCULATE([Count_Rows_J],FILTER('Jira Datalake','Jira Datalake'[Status Open vs Closed items (groups)] = "Closed" && 'Jira Datalake'[Closed] >= TODAY()-30))
 
 
RETURN "-" & COALESCE(created,0) // shows '0' instead of "(empty)"
 
 
Regarding your question, yes [Count_Rows_J] is a measure which count the numer of rows of the table

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

@BaronSdG , Try like this with date table

Rolling 30 = CALCULATE([Count_Rows_J],DATESINPERIOD('Date'[Date],today(),-30,Dau)'Jira Datalake'[Status Open vs Closed items (groups)] = "Closed")

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

BaronSdG
Resolver II
Resolver II

Wow thanks both @parry2k and  @Greg_Deckler for the fast response! Unfortunately, both solutions are not working. I am posting here the full code I have tried after your response

 

_Count_Closed_30days_dynStr =
VAR _30date = TODAY() - 30
VAR created = CALCULATE([Count_Rows_J],'Jira Datalake'[Status Open vs Closed items (groups)] = "Closed", 'Jira Datalake'[Closed] >= _30date)
 
RETURN "-" & COALESCE(created,0) // shows '0' instead of "(empty)"
 
Edit
Also, I think you use different simbles of < and > in your formulas

@BaronSdG - What is [Count_Rows_J] ? is that a measure? If so can you post the code? Also, posting sample data and expected output would assist greatly. 

 

First check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler I have used both formulas and I was able to fix yours, which was just missing the table name after FILTER. This formula is now working.

 

_Count_Closed_30days_dynStr =
VAR created = CALCULATE([Count_Rows_J],FILTER('Jira Datalake','Jira Datalake'[Status Open vs Closed items (groups)] = "Closed" && 'Jira Datalake'[Closed] >= TODAY()-30))
 
 
RETURN "-" & COALESCE(created,0) // shows '0' instead of "(empty)"
 
 
Regarding your question, yes [Count_Rows_J] is a measure which count the numer of rows of the table

My bad, that's what happens when I wing it.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@BaronSdG when you said not working, are you getting the wrong result and there is an error in the DAX measure? It is not clear what is not working.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@BaronSdG create a variable then use that in your formula

 

Measure = 
VAR __date = TODAY() - 30
RETURN
CALCULATE([Count_Rows_J],'Jira Datalake'[Status Open vs Closed items (groups)] = "Closed",
'Jira Datalake'[Closed Date] <= __date)

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Greg_Deckler
Super User
Super User

@BaronSdG - Perhaps:

 

CALCULATE([Count_Rows_J],FILTER('Jira Datalake'[Status Open vs Closed items (groups)] = "Closed" && [Date] >= TODAY()-30)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.