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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
akhaliq7
Post Prodigy
Post Prodigy

Help with Matrix

I would like my matrix to look like the below in Power BI:

 

Matrix_1.png

 

Below is my current DAX code:

Admin = 
VAR StartDate = 
CALCULATE(
	STARTOFYEAR('DimDate'[Date]),
	DimDate[Date] = EDATE(TODAY(),-1)
)
VAR EndDate =
CALCULATE(
	ENDOFMONTH(DimDate[Date]),
	DimDate[Date] = EDATE(TODAY(),-1)
)
RETURN
CALCULATE(
    COUNT('Training'[#]),
    'Training'[Department] = "Admin",
	KEEPFILTERS(DimDate[Date] >= StartDate),
	KEEPFILTERS(DimDate[Date] <= EndDate)
)

 

The problem with above is zeros do not show in the date range specified, also when I  add coalesce(query,0) then zeros are added to every month row, I would only like months jan, feb to show as the current month checks are incomplete, don't want future months to show either, and my date table is from januaury to December 2024.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @akhaliq7 

 

You can add a relative date filter or a relative date slicer to show last 2 months. 

Create a relative date slicer or filter in Power BI - Power BI | Microsoft Learn

 

Or try a measure like

Measure = 
IF (
    MONTH ( MAX ( DimDate[Date] ) ) < MONTH ( TODAY () ),
    COALESCE ( [your measure], 0 ),
    BLANK ()
)

 

BTW, it seems you are computing something like YTD, you may try something simpler for the measure

CALCULATE (
    [measure],
    DATESYTD ( 'Date'[Date] )
)

Basics of Time Intelligence in DAX for Power BI; Year to Date, Quarter to Date, Month to Date - RADA...

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @akhaliq7 

 

You can add a relative date filter or a relative date slicer to show last 2 months. 

Create a relative date slicer or filter in Power BI - Power BI | Microsoft Learn

 

Or try a measure like

Measure = 
IF (
    MONTH ( MAX ( DimDate[Date] ) ) < MONTH ( TODAY () ),
    COALESCE ( [your measure], 0 ),
    BLANK ()
)

 

BTW, it seems you are computing something like YTD, you may try something simpler for the measure

CALCULATE (
    [measure],
    DATESYTD ( 'Date'[Date] )
)

Basics of Time Intelligence in DAX for Power BI; Year to Date, Quarter to Date, Month to Date - RADA...

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

Thanks for your help. I used the relative date filter and will try out the measures later.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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