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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ved_Prakash
Frequent Visitor

Curren week measure

both the measure are returning same value throughout the column, please correct

 

CW Cancellation =
VAR CW =
    CALCULATE ( MAX ( vw_community_care_cancellation_report[weeknumber] ), ALLSELECTED (vw_community_care_cancellation_report ) )
RETURN
    CALCULATE (
        COUNTA( vw_community_care_cancellation_report[bookingid] ),
        FILTER ( ALLSELECTED (vw_community_care_cancellation_report ), (vw_community_care_cancellation_report[weeknumber] = CW )
    ))
 
CW Cancellations = CALCULATE( COUNTA( 'vw_community_care_cancellation_report'[bookingid] ), FILTER( ALL( 'vw_community_care_cancellation_report' ), 'vw_community_care_cancellation_report'[weeknumber] = WEEKNUM( TODAY(), 2 ) ) )
1 ACCEPTED SOLUTION
tmack99
Advocate II
Advocate II

It looks like both measures are returning the same value because they are calculating the count of bookingid in the same context (i.e., the same filter is applied to the vw_community_care_cancellation_report table in both measures). The first measure is using a variable CW to store the maximum value of weeknumber in the table, and then using that variable in the FILTER function to return the count of bookingid for that week. The second measure is using the WEEKNUM function to get the current week number (relative to the first week of the year), and then using that value in the FILTER function to return the count of bookingid for that week. Since both measures are effectively doing the same thing (counting the number of bookingid for the current week), they will return the same value.

To fix the problem, you will need to modify the measures to calculate different values. For example, you could modify the first measure to calculate the count of bookingid for the previous week instead of the current week. Here is one way you could do that:

CW Cancellations =
VAR PreviousWeek =
CALCULATE (
MAX ( vw_community_care_cancellation_report[weeknumber] ),
ALLSELECTED (vw_community_care_cancellation_report ),
vw_community_care_cancellation_report[weeknumber] < WEEKNUM(TODAY(), 2)
)
RETURN
CALCULATE (
COUNTA( vw_community_care_cancellation_report[bookingid] ),
FILTER ( ALLSELECTED (vw_community_care_cancellation_report ), (vw_community_care_cancellation_report[weeknumber] = PreviousWeek )
))
This measure uses a variable PreviousWeek to store the maximum value of weeknumber in the table that is less than the current week number (as calculated by the WEEKNUM function). Then, it uses that variable in the FILTER function to return the count of bookingid for the previous week. This will give you a different value than the second measure, which calculates the count of bookingid for the current week.

 



 

View solution in original post

2 REPLIES 2
tmack99
Advocate II
Advocate II

It looks like both measures are returning the same value because they are calculating the count of bookingid in the same context (i.e., the same filter is applied to the vw_community_care_cancellation_report table in both measures). The first measure is using a variable CW to store the maximum value of weeknumber in the table, and then using that variable in the FILTER function to return the count of bookingid for that week. The second measure is using the WEEKNUM function to get the current week number (relative to the first week of the year), and then using that value in the FILTER function to return the count of bookingid for that week. Since both measures are effectively doing the same thing (counting the number of bookingid for the current week), they will return the same value.

To fix the problem, you will need to modify the measures to calculate different values. For example, you could modify the first measure to calculate the count of bookingid for the previous week instead of the current week. Here is one way you could do that:

CW Cancellations =
VAR PreviousWeek =
CALCULATE (
MAX ( vw_community_care_cancellation_report[weeknumber] ),
ALLSELECTED (vw_community_care_cancellation_report ),
vw_community_care_cancellation_report[weeknumber] < WEEKNUM(TODAY(), 2)
)
RETURN
CALCULATE (
COUNTA( vw_community_care_cancellation_report[bookingid] ),
FILTER ( ALLSELECTED (vw_community_care_cancellation_report ), (vw_community_care_cancellation_report[weeknumber] = PreviousWeek )
))
This measure uses a variable PreviousWeek to store the maximum value of weeknumber in the table that is less than the current week number (as calculated by the WEEKNUM function). Then, it uses that variable in the FILTER function to return the count of bookingid for the previous week. This will give you a different value than the second measure, which calculates the count of bookingid for the current week.

 



 

tamerj1
Super User
Super User

Hi @Ved_Prakash 

can you provide a screenshot of the results that you are getting?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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