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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Yul
New Member

How to create a new measure for dates

Hi 

I have two tables with two different ranges of dates, I want to create a new slicer to filter both by month and year

How can I do this with a new measure ?

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Yul ,

I created some data:

TableA:

vyangliumsft_5-1662443262344.png

TableB:

vyangliumsft_6-1662443267037.png

Table:

vyangliumsft_2-1662443233466.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _selectmin=MINX(ALLSELECTED('Table'),[Date])
var _selectmax=MAXX(ALLSELECTED('Table'),[Date])
return
IF(
    AND(
       MAX('TableA'[Date])>=_selectmin,MAX('TableA'[Date])<=_selectmax)
    ||
    AND(
        MAX('TableB'[Date])>=_selectmin,MAX('TableB'[Date])<=_selectmax)
        ,1
        ,0)

2. Place [Flag] in Visual's Filter and set is=1.

vyangliumsft_3-1662443233467.png

3. Result:

vyangliumsft_4-1662443233472.png

If you need pbix, please click here.

How to create a new measure for dates.pbix

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi  @Yul ,

I created some data:

TableA:

vyangliumsft_5-1662443262344.png

TableB:

vyangliumsft_6-1662443267037.png

Table:

vyangliumsft_2-1662443233466.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _selectmin=MINX(ALLSELECTED('Table'),[Date])
var _selectmax=MAXX(ALLSELECTED('Table'),[Date])
return
IF(
    AND(
       MAX('TableA'[Date])>=_selectmin,MAX('TableA'[Date])<=_selectmax)
    ||
    AND(
        MAX('TableB'[Date])>=_selectmin,MAX('TableB'[Date])<=_selectmax)
        ,1
        ,0)

2. Place [Flag] in Visual's Filter and set is=1.

vyangliumsft_3-1662443233467.png

3. Result:

vyangliumsft_4-1662443233472.png

If you need pbix, please click here.

How to create a new measure for dates.pbix

 

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

Whitewater100
Solution Sage
Solution Sage

Hi:

Assuming you do not have a continuous date table, you would need to add a date table (the month-year column) will filter both of your other tablesafter forming a relationship on the date field.You should also mark your date table as a date table. Here is some code below(table name = "Dates"  you can use to create a date table. 

MODELING>NEW TABLE> then this code:

Dates = ADDCOLUMNS ( CALENDAR (DATE(2020,01,01), TODAY()), "year", YEAR ( [Date] ), "MonthNumber", FORMAT ( [Date], "MM" ), "year-month", FORMAT ( [Date], "YYYY-MM" ), "month-year", FORMAT ( [Date], "MM-'YY" ) )

 

I hope this helps!

daXtreme
Solution Sage
Solution Sage

Create a new date table that will have dates from both tables and connect it to the other ones. I don't understand what you mean by "How can I do this with a new measure?." But I don't even understand why you have 2 different date tables... You should have one that stores dates that span the whole period you want to work with in any of your other tables. By the way, you should have one calendar in your model. If you have 2 tables with dates in them, then you should create a calendar and connect it to the tables. Why complicate things that can be simple?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.