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

Calculate the month from a date slicer..

Hello All,

I had a requirement that calculated the no. of failed jobs for the month for a selected date. My dashboard at the moment displays day wise data for a particular selected date. What I would like to calculate is for the month of the selected date, how many jobs have failed. Is there a way to do this without putting a month slicer?

 

For now I have created a measure - calculate(sum(data[statuscounts]), data[status] = "Failed"). This works well if I use a month slicer

 

Regards

1 ACCEPTED SOLUTION
Jos_Woolley
Solution Sage
Solution Sage

Hi,

Assuming your slicer is from a date table named 'Dates' (which has a relationship with your 'data' table):

MyMeasure = 
VAR MyDate =
    SELECTEDVALUE( Dates[Date] )
RETURN
    CALCULATE(
        SUM( data[statuscounts] ),
        data[status] = "Failed",
        FORMAT( Dates[Date], "mm-yy" ) = FORMAT( MyDate, "mm-yy" )
    )

Regards

 

View solution in original post

7 REPLIES 7
Jos_Woolley
Solution Sage
Solution Sage

Hi,

Assuming your slicer is from a date table named 'Dates' (which has a relationship with your 'data' table):

MyMeasure = 
VAR MyDate =
    SELECTEDVALUE( Dates[Date] )
RETURN
    CALCULATE(
        SUM( data[statuscounts] ),
        data[status] = "Failed",
        FORMAT( Dates[Date], "mm-yy" ) = FORMAT( MyDate, "mm-yy" )
    )

Regards

 

Hi @Jos_Woolley 

This works! However, is there a way to modify it using the before/after date selection? since I am using a single date picker

 

Really appreciate your help! Thank you

Not sure what you mean, sorry. Can you clarify?

Regards

@Jos_Woolley  I was able to fix the issue on my end. I did have a question regarding your calculation though - for the month of July I am getting 0 failures till date. However, say there was 1 failure on July 29th. Will the value then show 1 for the month? That is, will it aggregate day on day?

 

Regards

I'm afraid I don't understand your new request either. The measure does precisely what you asked: whatever the month of the entry you choose in the date slicer, it will return the required sum for all entries with that month and year. Or were you wanting perhaps to include months from different years in the same total?

Regards

@Jos_Woolley  Sorry I should have been more clear. I was just wondering how the measure would behave when the data refreshes. This report refreshes daily. For the past months, the measure is working as expected. Just wanted to understand the behaviour once it refreshes and there is a failure for a particular day. For example, for July 2022, there have been 0 failures till date. if the data refreshes tomorrow and there is 1 failure, will the measure now reflect 1 for July?

 

Regards

Yes, the measure will recalculate when your data is refreshed.

Regards

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.