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
MichaiahGartner
Frequent Visitor

Filtering/finding most common month & week with a Date/Time Format

I have a table that lists invoices along with a date column that is formatted like 12/12/2012 12:00:00 AM. I want to find (through DAX) the most frequently occuring month and week but am now sure how. 

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

  1. Create a Calendar Table with the following calculated colums to extract Month and Week: Month=FORMAT(Calendar[Date],"mmmm") and Week=WEEKNUM(Calendar[Date])
  2. Create a relationship from the Date column of your Data Table to the Date column of your Calendar Table
  3. Write this measure

Invoice count=COUNTA(Data[Invoice Number])

 

You may sort the measure in descending order.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

v-frfei-msft
Community Support
Community Support

Hi @MichaiahGartner,

 

As davehus metioned, I made one sample for your reference.

 

1. Enter the sample data and create some calculated columns in the table.

Month = FORMAT(Invoice[Date],"mmmm")
weeknum = WEEKNUM(Invoice[Date])

2. Create the measures to achieve your goal.

 

Invoice Count Measure = COUNT(Invoice[Month])
Top Month = 
IF (
    NOT ( ISBLANK ( Invoice[Invoice Count Measure] ) ),
    MAXX (
        TOPN (
            1,
            SUMMARIZE (
                Invoice,
                Invoice[Month],
                "Invoice Count", Invoice[Invoice Count Measure]
            ),
            [Invoice Count]
        ),
        Invoice[Month]
    )
)
Top week = 
IF (
    NOT ( ISBLANK ( Invoice[Invoice Count Measure] ) ),
    MAXX (
        TOPN (
            1,
            SUMMARIZE (
                Invoice,
                Invoice[weeknum],
                "Invoice Count", Invoice[Invoice Count Measure]
            ),
            [Invoice Count]
        ),
        Invoice[weeknum]
    )
)

Capture.PNG

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

4 REPLIES 4
v-frfei-msft
Community Support
Community Support

Hi @MichaiahGartner,

 

As davehus metioned, I made one sample for your reference.

 

1. Enter the sample data and create some calculated columns in the table.

Month = FORMAT(Invoice[Date],"mmmm")
weeknum = WEEKNUM(Invoice[Date])

2. Create the measures to achieve your goal.

 

Invoice Count Measure = COUNT(Invoice[Month])
Top Month = 
IF (
    NOT ( ISBLANK ( Invoice[Invoice Count Measure] ) ),
    MAXX (
        TOPN (
            1,
            SUMMARIZE (
                Invoice,
                Invoice[Month],
                "Invoice Count", Invoice[Invoice Count Measure]
            ),
            [Invoice Count]
        ),
        Invoice[Month]
    )
)
Top week = 
IF (
    NOT ( ISBLANK ( Invoice[Invoice Count Measure] ) ),
    MAXX (
        TOPN (
            1,
            SUMMARIZE (
                Invoice,
                Invoice[weeknum],
                "Invoice Count", Invoice[Invoice Count Measure]
            ),
            [Invoice Count]
        ),
        Invoice[weeknum]
    )
)

Capture.PNG

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @MichaiahGartner,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case.

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

  1. Create a Calendar Table with the following calculated colums to extract Month and Week: Month=FORMAT(Calendar[Date],"mmmm") and Week=WEEKNUM(Calendar[Date])
  2. Create a relationship from the Date column of your Data Table to the Date column of your Calendar Table
  3. Write this measure

Invoice count=COUNTA(Data[Invoice Number])

 

You may sort the measure in descending order.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
davehus
Memorable Member
Memorable Member

Top Month = 

IF (
    NOT ( ISBLANK ( "Invoice Count Measure" ) ),
    MAXX (
        TOPN (
            1,
            SUMMARIZE (
                'Your Table',
                'Date Table'[Month Name],
                "Invoice Count", "Invoice Count Measure"
            ),
            [Invoice Count]
        ),
        'Date Table'[Month Name]
    )
)

Hi - Please see the measure I've included for you. I'm assuming that you have a date table linked to the table and the measure is written with this in mind. 

 

Hopefull this helps.

 

D

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.