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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
snoozee
Regular Visitor

Weekly Check Calculation

Hi

 

I have a table that contains the following columns

 

Location, Date, CheckNotCompleted. WeekNumber and Year

 

My CheckNotCompleted column contains a Yes or No response

 

I need DAX to create a new column that will look at the CheckNotCompleted column for each week number and Location and if the week for that location has a Yes response in it then return Yes for all of the relavent week days for that week, if the column doesn't have a Yes response for that week then the reponse would be No..

 

Is this possible ??

1 ACCEPTED SOLUTION

Hi @snoozee ,

 

Based on the screenshot you provided, you need to change the code slightly as follows.

Weekly Check = 
VAR CurrentLocation = 'Table'[Location]
VAR Cnt =
    CALCULATE (
        COUNT ( 'Table'[CheckNotCompleted] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[WeekNumber] ),
            'Table'[CheckNotCompleted] = "Yes"
                && 'Table'[Location] = CurrentLocation
        )
    )
RETURN
    IF ( Cnt >= 1, "Y", "N" )

Result is as below.

vweiyan1msft_0-1708999239165.png

Hope that works for you.
For further details,please find attachment.


Best Regards,
Yulia Yan


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

6 REPLIES 6
v-weiyan1-msft
Community Support
Community Support

Hi @snoozee ,

 

@Jihwan_Kim nice method! Thank you, for your helpful and quick response.

And you can also consider using the following code to create a Calculated column.

Weekly Check = 
VAR CurrentLocation = 'Table'[Location]
VAR Cnt =
    CALCULATE (
        COUNT ( 'Table'[CheckNotCompleted] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[WeekNumber] ),
            'Table'[CheckNotCompleted] = "Y"
                && 'Table'[Location] = CurrentLocation
        )
    )
RETURN
    IF ( Cnt >= 1, "Y", "N" )

My Sample:

vweiyan1msft_0-1708323429379.png

Result is as below.

vweiyan1msft_1-1708323444411.png

 

Best Regards,
Yulia Yan


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

Hi @v-weiyan1-msft 

Thanks for getting back to me yet unfortunately it's not working as all of the results are 'N'  😣

The example below should be displaying 'Y' for all of these dates as a check was completed within the week.

 

snoozee_0-1708974239283.png

Weekly Check =
VAR CurrentLocation = 'CameraDate'[Branch]
VAR Cnt =
CALCULATE (
COUNT ( 'CameraDate'[CheckNotCompleted] ),
FILTER (
ALLEXCEPT ( 'CameraDate', 'CameraDate'[WeekNumber] ),
'CameraDate'[CheckNotCompleted] = "Y"
&& 'CameraDate'[Branch] = CurrentLocation
)
)
RETURN
IF ( Cnt >= 1, "Y", "N" )

 

 

 

Hi @snoozee ,

 

Based on the screenshot you provided, you need to change the code slightly as follows.

Weekly Check = 
VAR CurrentLocation = 'Table'[Location]
VAR Cnt =
    CALCULATE (
        COUNT ( 'Table'[CheckNotCompleted] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[WeekNumber] ),
            'Table'[CheckNotCompleted] = "Yes"
                && 'Table'[Location] = CurrentLocation
        )
    )
RETURN
    IF ( Cnt >= 1, "Y", "N" )

Result is as below.

vweiyan1msft_0-1708999239165.png

Hope that works for you.
For further details,please find attachment.


Best Regards,
Yulia Yan


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

@v-weiyan1-msft  Thank you so much for this and my apoligies as my brain obvioulsy wasn't working yesterday as i should have picked up the 'Y' rather the 'Yes' 😊

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1707883100531.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Expected result CC =
VAR _t =
    FILTER (
        WINDOW (
            1,
            ABS,
            -1,
            ABS,
            Data,
            ORDERBY ( Data[Date], ASC ),
            ,
            PARTITIONBY ( Data[Location], Data[Year], Data[Week Number] ),
            MATCHBY ( Data[Location], Data[Date] )
        ),
        Data[CheckNotCompleted] = "Y"
    )
RETURN
    IF ( COUNTROWS ( _t ) >= 1, "Y", "N" )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

@Jihwan_Kim  Thank you so much for replying so quickly !!

 

Unfortunately this doesn't work for me as i'm getting an error of - Cannot find name 'Window' , 'Window' is not a function, Parameter is not the correct type.

 

This is probably related to the version of Power Bi I'm using  - May 2021 and unfortunately i can't update it as it's controlled by my work 😞

 

This is also the reason why i can't open your attachment either.

 

Is there any other option available ?

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.