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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PPStar
Helper V
Helper V

Filter table to show data for current month

Hi, 

 

i have a table (Called Records) which looks like below

 

Number | Created On 

12432    | 12/4/2021

332535  | 15/05/2022

334525 | 01/01/2023

435315 | 14/01/2023

335325 | 2/5/2021

 

The table has around 55,0000 rows of data. 

I need to be able to write a DAX which shows me data for the current year and month only. 

 

The Records Table has a 1:M relationship with a date table. The Date Table has info as below

PPStar_0-1673432574998.png

 

I have been trying to use the Filter(Summarize) Function, but to no avail. 

 

What i need is every month, this DAX query should run (via power automate) and show data for Jan, Feb, March, so i can then archive the data. 

 

Can someone please show me how i can write some DAX to only show Records data for the current month, so it can automatically just run?

 

Thanks

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @PPStar ,

 

Here are the steps you can follow:

1. Create calculated table.

 

records =
var _table=
SUMMARIZE(
    'Table','Table'[Create On],'Table'[Number],"Year",YEAR('Table'[Create On]),"Month",MONTH('Table'[Create On]))
return
FILTER(
    _table,[Year]=YEAR(TODAY())&&[Month]=MONTH(TODAY()))

 

2. Result:

vyangliumsft_0-1673600279848.png

Does it meet your expected results

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @PPStar ,

 

Here are the steps you can follow:

1. Create calculated table.

 

records =
var _table=
SUMMARIZE(
    'Table','Table'[Create On],'Table'[Number],"Year",YEAR('Table'[Create On]),"Month",MONTH('Table'[Create On]))
return
FILTER(
    _table,[Year]=YEAR(TODAY())&&[Month]=MONTH(TODAY()))

 

2. Result:

vyangliumsft_0-1673600279848.png

Does it meet your expected results

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

v-yangliu-msft
Community Support
Community Support

Hi  @PPStar ,

I created some data:

Date:

vyangliumsft_0-1673510543688.png

Here are the steps you can follow:

Create calculated table.

Monthly data:

Every Month =
var _table=SUMMARIZE('Date','Date'[Year],'Date'[Month])
return
ADDCOLUMNS(
    _table,"Value",
    SUMX(FILTER(ALL('Table'),
    YEAR('Table'[Create On]) =[Year] && MONTH('Table'[Create On]) =[Month]),[Number]))

vyangliumsft_1-1673510543689.png

Current month's data:

Current Month =
var _table=
SUMMARIZE('Date','Date'[Year],'Date'[Month])
var _table2=
FILTER(
    _table,
    [Year] = YEAR(TODAY()) && [Month] =MONTH(TODAY()))
return
ADDCOLUMNS(
    _table2,"Value",
    SUMX(FILTER(ALL('Table'),
    YEAR('Table'[Create On]) =[Year] && MONTH('Table'[Create On]) =[Month]),[Number]))

vyangliumsft_2-1673510543689.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thanks for this. But would this return me the records for that month?. I need to see all the records for that particular month, not the value of records?

MAwwad
Super User
Super User

 

You can use the FILTER() and SUMMARIZE() functions in DAX to filter your data based on the current year and month. Here's an example of a DAX formula that should do this:

 

Copy code
FILTER( SUMMARIZE( FILTER(Records, 'Date'[Year] = YEAR(NOW()) && 'Date'[MonthNumber] = MONTH(NOW())), 'Date'[Number], "NumberCount", COUNTX(CURRENTGROUP(), 'Date'[Number]) ), [NumberCount] > 0 )
 

This formula first filters your "Records" table based on the current year and month using the year and month columns in your date table. Then it summarizes the filtered data by counting the number of records for each "Number" value. Finally, it filters the summarized data to only include values with a count greater than zero.

This doesnt work. 

FILTER(SUMMARIZE(FILTER(Records,  - from here, i am unable to select my date table ?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.