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
BOti62
Regular Visitor

Power BI Dax Measure to calculate total sum of errors on the Prev day of everyday in current month

Hi all

I am trying to create a dax formula which lets me create the below table in power bi but have come across issues. 

 

This is the measure I've tried to use but it does not work:

 

 PreviousDayToStartOfMonthErrors = VAR CurrentDate = TODAY() VAR StartOfMonth = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1) VAR PreviousDay = CurrentDate - 1 // 

RETURN CALCULATE( SUMX( DISTINCT(DataQualityDashboard[RuleImplementationID]),

CALCULATE( SUM(DataQualityDashboard[ErrorCount]), DataQualityDashboard[DateStamp] >= DATE(YEAR(StartOfMonth), MONTH(StartOfMonth), DAY(StartOfMonth) - 1) && DataQualityDashboard[DateStamp] <= PreviousDay ) ) )

DateErrors Month To DatePrevious Day
01-Jan-24505278 
02-Jan-24505678505278
03-Jan-24505245505678
04-Jan-24503607505245

Is anyone able to help please?

3 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

This seems to be missing some important details. Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

 

Consider using OFFSET -1

View solution in original post

Anonymous
Not applicable

Hi @BOti62 ,

Not being able to fully understand your needs based only on the information you provided, I tried to modify the DAX a bit:

PreviousDayToStartOfMonthErrors =
VAR CurrentDate = TODAY()
VAR StartOfMonth = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1)
VAR PreviousDay = CurrentDate - 1
RETURN
CALCULATE(
    SUM(DataQualityDashboard[ErrorCount]),
    FILTER(
        DataQualityDashboard,
        DataQualityDashboard[DateStamp] >= StartOfMonth &&
        DataQualityDashboard[DateStamp] <= PreviousDay
    )
)

If this is still not possible, please provide the full sample data and data model, as well as example screenshots of the results you would like to get, thank you!

Best Regards,
Dino Tao
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

Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table.  Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table.  To your visual/filter/slicer, drag Date from the Calendar Table.  Write these measures:

Errors = counta(Data[Error])

Errors on previous day = calculate([errors],previousday(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table.  Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table.  To your visual/filter/slicer, drag Date from the Calendar Table.  Write these measures:

Errors = counta(Data[Error])

Errors on previous day = calculate([errors],previousday(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @BOti62 ,

Not being able to fully understand your needs based only on the information you provided, I tried to modify the DAX a bit:

PreviousDayToStartOfMonthErrors =
VAR CurrentDate = TODAY()
VAR StartOfMonth = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1)
VAR PreviousDay = CurrentDate - 1
RETURN
CALCULATE(
    SUM(DataQualityDashboard[ErrorCount]),
    FILTER(
        DataQualityDashboard,
        DataQualityDashboard[DateStamp] >= StartOfMonth &&
        DataQualityDashboard[DateStamp] <= PreviousDay
    )
)

If this is still not possible, please provide the full sample data and data model, as well as example screenshots of the results you would like to get, thank you!

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

lbendlin
Super User
Super User

This seems to be missing some important details. Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

 

Consider using OFFSET -1

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.