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
Anonymous
Not applicable

Previous 6 Months Per Month

I have a table of bugs that has two main fields: environment and created date. I need to get the total number of bugs by environment for the past 6 months for each month. I tried many solutions I found online but nothing seemed to work. 

 

I currently have multiple measures that calculate the number of bugs by environment per month, this is what those look like:

Production Bugs = COUNTROWS(FILTER(Bugs, Bugs[env] = "Production" && Bugs[createdDate] = Bugs[createdDate]))+0
 
I have a feeling I am making this much more complicated than it needs to be, but can't seem to get it working. I am relatively new to Power BI and DAX, although I do know the basics.
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

You can try to use the following measure formula if it meets your requirement:

Production Bugs =
VAR currDate =
    MAX ( Bugs[createdDate] )
RETURN
    COUNTROWS (
        FILTER (
            ALLSELECTED ( Bugs ),
            Bugs[env] = "Production"
                && Bugs[createdDate]
                    >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 6, DAY ( currDate ) )
                && Bugs[createdDate] <= currDate
        )
    ) + 0

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

You can try to use the following measure formula if it meets your requirement:

Production Bugs =
VAR currDate =
    MAX ( Bugs[createdDate] )
RETURN
    COUNTROWS (
        FILTER (
            ALLSELECTED ( Bugs ),
            Bugs[env] = "Production"
                && Bugs[createdDate]
                    >= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 6, DAY ( currDate ) )
                && Bugs[createdDate] <= currDate
        )
    ) + 0

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , you can use relative date slicer or this approach

https://www.youtube.com/watch?v=duMSovyosXE

 

relative date slicer

https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range

 

 

Anonymous
Not applicable

I need the actual data as I need to use it for other calculations. So it would need to be a measure I think.

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.