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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
razieh12
Frequent Visitor

Matrix visualizations and dynamically expand the last month, last week of the last month

Hello. 
 I created matrix in power bi, the rows are months, weeks, and days. and the value is %sale.

My goal is to enable expansion solely for the most recent month. From there, I desire only the last week of that month to be expandable, while keeping all other periods unexpanded. Importantly, I'm aiming for this behavior to be dynamic—no matter the updates to data or dates, the expansion setup should remain consistent as I've outlined

razieh12_0-1693243132554.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @razieh12,

I'd like to suggest you create a matrix with complete date range and Dax expression calculation result. You can create a measure formula to check the current date value and return flag.

After these steps, you can use this as condition to use on ‘visual level filter’ to filter records based on flag.

Sample formulas:

lastMonth flag =
VAR currDate =
    MAX ( Table1[Date] )
VAR _sysDate =
    TODAY ()
RETURN
    IF ( currDate < DATE ( YEAR ( _sysDate ), MONTH ( _sysDate ), 1 ), "Y", "N" )
    
lastweek flag =
VAR currDate =
    MAX ( Table1[Date] )
VAR _sysDate =
    TODAY ()
VAR weekdayOffset =
    WEEKDAY ( _sysDate )
RETURN
    IF (
        currDate
            <= DATE ( YEAR ( _sysDate ), MONTH ( _sysDate ), DAY ( _sysDate ) - weekdayOffset ),
        "Y",
        "N"
    )

Applying a measure filter in Power BI - SQLBI

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @razieh12,

I'd like to suggest you create a matrix with complete date range and Dax expression calculation result. You can create a measure formula to check the current date value and return flag.

After these steps, you can use this as condition to use on ‘visual level filter’ to filter records based on flag.

Sample formulas:

lastMonth flag =
VAR currDate =
    MAX ( Table1[Date] )
VAR _sysDate =
    TODAY ()
RETURN
    IF ( currDate < DATE ( YEAR ( _sysDate ), MONTH ( _sysDate ), 1 ), "Y", "N" )
    
lastweek flag =
VAR currDate =
    MAX ( Table1[Date] )
VAR _sysDate =
    TODAY ()
VAR weekdayOffset =
    WEEKDAY ( _sysDate )
RETURN
    IF (
        currDate
            <= DATE ( YEAR ( _sysDate ), MONTH ( _sysDate ), DAY ( _sysDate ) - weekdayOffset ),
        "Y",
        "N"
    )

Applying a measure filter in Power BI - SQLBI

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.