Forum Discussion

Alta88's avatar
Alta88
Helper IV
2 years ago
Solved

Card Visual - Troubleshoot

My card visual should show total errors from the previous day's accounts but it's returning 'blank': 

 

 

 

I've used the following measure for the field value: 

 

Error Count =
VAR CurrentDate = TODAY()
VAR PrevDay = TODAY() - 1
VAR DayOfWeek = WEEKDAY(CurrentDate, 2) -- 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday, 7 = Saturday, 1 = Sunday

VAR SelectedDate = IF(DayOfWeek = 1, PrevDay - 1, CurrentDate)

RETURN
    CALCULATE(
        COUNTROWS('DataPool Merge 2024'),
        'DataPool Merge 2024'[Date] = SelectedDate,
        'DataPool Merge 2024'[Status] = "Error"
    )
 
 
This is my table layout: 
 

 

Do I need to rename fields or tables in the DAX measure? 

  • Alta88 

    You can use the following adjusted DAX expression:

    Error Count = 
    VAR CurrentDate = TODAY()
    VAR PrevDay = CurrentDate - 1
    VAR DayOfWeek = WEEKDAY(CurrentDate, 2) -- 2 = Monday, 7 = Sunday
    VAR SelectedDate = 
        IF(
            DayOfWeek = 1, -- If today is Monday, check for Friday's data
            CurrentDate - 3,
            PrevDay
        )
    RETURN 
        CALCULATE(
            COUNTROWS('Table'),
            'Table'[Date] = SelectedDate,
            'Table'[Status] = "Error"
        )

    The results are as follows:

     

     

    Best Regards

    hackcrr

    If I have answered your question, please mark my reply as solution and kudos to this post, thank you!

     

2 Replies

  • hackcrr's avatar
    hackcrr
    Memorable Member

    Alta88 

    You can use the following adjusted DAX expression:

    Error Count = 
    VAR CurrentDate = TODAY()
    VAR PrevDay = CurrentDate - 1
    VAR DayOfWeek = WEEKDAY(CurrentDate, 2) -- 2 = Monday, 7 = Sunday
    VAR SelectedDate = 
        IF(
            DayOfWeek = 1, -- If today is Monday, check for Friday's data
            CurrentDate - 3,
            PrevDay
        )
    RETURN 
        CALCULATE(
            COUNTROWS('Table'),
            'Table'[Date] = SelectedDate,
            'Table'[Status] = "Error"
        )

    The results are as follows:

     

     

    Best Regards

    hackcrr

    If I have answered your question, please mark my reply as solution and kudos to this post, thank you!