cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Community Support

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.

Hope that works for you.

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.

6 REPLIES 6
Community Support

Hi @snoozee ,

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:

Result is as below.

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.

Regular Visitor

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.

Weekly Check =
VAR Cnt =
CALCULATE (
FILTER (
)
)
RETURN
IF ( Cnt >= 1, "Y", "N" )

Community Support

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.

Hope that works for you.

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.

Regular Visitor

@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' 😊

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.

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.

Regular Visitor

@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 ?

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors