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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
romovaro
Responsive Resident
Responsive Resident

Review Custom formulas

Hello

 

Pls, can you review my formulas to help me understand the error?

 

I have the table below:

 

CLIENT_NAMECIDTASKTASK_ASSIGNED_ONTASK_STATUSTASK_COMPLETED_DATETASKACTUALPERFORMERCUID
Client A1000702Pre Engagement Process04-feb-22Closed18-feb-22John Smith 
Client B1000542Pre Engagement Process03-feb-22Closed11-feb-22Will Smith 
Client C1000603Pre Engagement Process02-feb-22Closed04-feb-22Jorge Fernandez 
Client D1000461Pre Engagement Process01-feb-22Closed18-feb-22Juan valdes 
Client E1000583Pre Engagement Process17-ene-22Closed17-JAN-22 John Smith 
Client E1000583Partner Acknowledgement - 1233528 - 1000583MY0102-feb-22Closed04-feb-22ibmbpmadmin1000583MY01
Client E1000582Start Partner Engagement - 1233528 - 1000583BE0120-JAN-21Closed01-feb-22Juan valdes1000583BE01
Client E1000583Start Partner Engagement - 1233528 - 1000583MY0120-JAN-22 Closed02-feb-22Juan valdes1000583MY01
Client E1000583Assign Implementation Consultant - 1233528 - 1000583MY0117-JAN-22 Received Jorge Fernandez1000583MY01
Client E1000583IPM HandOff17-JAN-22 Received Juan valdes 
Client E1000582Partner Assignment - 1233528 - 1000583BE0117-JAN-21Closed18-JAN-21John Smith1000583BE01
Client E1000583Partner Assignment - 1233528 - 1000583MY0117-JAN-22 Closed18-JAN-22John Smith1000583MY01
Client E1000583Resource Allocation17-JAN-22 Closed17-JAN-22ibmbpmadmin 

 

Where Task column can contain different tasks:

 

- Pre engagement Process

- Start partner Engagement

- Partner Acknowledgement 

- etc.

 

And I need to calculate the statetements below:

 

Total to Book:  Total number of CUIDS, where pre-engagement task is closed by Pre team member

 In the table, When Task = “Pre Engagement Process” and Task_status = Closed there is no CUID (unique customer number). I need to use the CID column and then Intersect with the CUID column (IN the table above, CID 1000583 has 2 different CUID. Blank space do not count)

I tried the formula below but something is wrong:

Total To Book2 =

var tab =

    CALCULATETABLE(

        VALUES('BPMS LOF Report'[CID]),

        FILTER (

            'BPMS LOF Report',

            'BPMS LOF Report'[TASK] = "Pre Engagement Process"

                && 'BPMS LOF Report'[TASK_STATUS]= "Closed"

                 && 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes"

    )

    return

    CALCULATE(

        DISTINCTCOUNT('BPMS LOF Report'[CUID]),

        INTERSECT(VALUES('BPMS LOF Report'[CID]), tab),

        FILTER (

        'BPMS LOF Report',

        CONTAINSSTRING ( 'BPMS LOF Report'[TASK], "Pre Engagement" )

            && 'BPMS LOF Report'[TASK_STATUS] = "Closed"

    )

)

 

Entities booked: total number CUIDs where prep team closed "start partner engagement" task and "Partner Ackn" is closed

 

I tried the formula below but something is wrong:

Entities Booked =

VAR MeetsFirstRequirement =

    CALCULATETABLE(

        VALUES('BPMS LOF Report'[CUID] ),

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Start Partner Engagement"

            && 'BPMS LOF Report'[TASK_STATUS] = "Closed"

        )

                 && 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes"

    )

VAR MeetsBothRequirements =

    CALCULATETABLE(

        VALUES( 'BPMS LOF Report'[CUID] ),

        MeetsFirstRequirement,

        'BPMS LOF Report'[TASK_STATUS] = "Closed",

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Partner Acknowledgement"

        )

    )

RETURN MeetsBothRequirements 

 

Entities to be confirmed: total number CUIDs here prep team closed start partner engagement task and Partner Ackn is not closed

(Same as the formula above but instead of Partner Acknoledgement Closed is Received.

I tried the formula below but something is wrong:

 

Entities to be confirmed =

VAR MeetsFirstRequirement =

VAR MeetsFirstRequirement =

    CALCULATETABLE(

        VALUES('BPMS LOF Report'[CUID] ),

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Start Partner Engagement"

            && 'BPMS LOF Report'[TASK_STATUS] = "Closed"

        )

                 && 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes"

    )

VAR MeetsBothRequirements =

    CALCULATETABLE(

        VALUES( 'BPMS LOF Report'[CUID] ),

        MeetsFirstRequirement,

        'BPMS LOF Report'[TASK_STATUS] = "Received",

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Partner Acknowledgement"

        )

    )

RETURN MeetsBothRequirements 

 

Could you offer any help with the formulas?

 

thanks

 

 

 

1 ACCEPTED SOLUTION

Now written as measures:

Total To Book = 
var tab=CALCULATETABLE(values('BPMS LOF Report'[CID]),
ALL('BPMS LOF Report'),
'BPMS LOF Report'[TASK]="Pre Engagement Process",
'BPMS LOF Report'[TASK_STATUS]="Closed",
'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith","Will Smith","Juan Valdes"})
return calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),all('BPMS LOF Report'),'BPMS LOF Report'[CID] in tab)

Entities Booked = 
calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),
       all('BPMS LOF Report'),
       'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith","Will Smith","Juan Valdes"},
       'BPMS LOF Report'[TASK_STATUS] = "Closed",
       CONTAINSSTRING('BPMS LOF Report'[TASK],"Start Partner Engagement") || CONTAINSSTRING('BPMS LOF Report'[TASK],"Partner Acknowledgement"))

Entities TBC = 
calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),
       all('BPMS LOF Report'),
       'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith","Will Smith","Juan Valdes"},
       'BPMS LOF Report'[TASK_STATUS] = "Closed" && CONTAINSSTRING('BPMS LOF Report'[TASK],"Start Partner Engagement") 
          || 'BPMS LOF Report'[TASK_STATUS] = "Received" && CONTAINSSTRING('BPMS LOF Report'[TASK],"Partner Acknowledgement"))

see attached

View solution in original post

15 REPLIES 15
romovaro
Responsive Resident
Responsive Resident

Hi Ibendin

 

Trying to write your code but unsuccesful. Sorry but my coding is not so good.

Which formula from the 2 above is better?

 

In the example below, I need to add the "containsstring" in the task because the name changes all the time...but the string "Partner Engagement" or "Partner acknowledgement" remains the same.

 

formula 1)

romovaro_0-1646660030388.png

2Entities Booked =
var tab =CALCULATETABLE (VALUES ( 'BPMS LOF Report'[CUID] ),
FILTER (
'BPMS LOF Report',
'BPMS LOF Report'[TASK_STATUS] = "Closed"
&& CONTAINSSTRING ( 'BPMS LOF Report'[TASK], "Partner Engagement" )
)
&& 'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith","Will Smith","Juan valdes"})
return CALCULATE (COUNTROWS('BPMS LOF Report'),
INTERSECT ( VALUES('BPMS LOF Report'[CUID]), tab ),
FILTER (
'BPMS LOF Report',
'BPMS LOF Report'[TASK_STATUS] = "Closed"
&& CONTAINSSTRING ( 'BPMS LOF Report'[TASK], "Partner Acknowledgement")
)
)
 
Formula 2) If I removed the && from the formula like your i get an error..
 

Entities Booked =

VAR MeetsFirstRequirement =

    CALCULATETABLE(

        VALUES('BPMS LOF Report'[CUID] ),

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Start Partner Engagement"

            && 'BPMS LOF Report'[TASK_STATUS] = "Closed"

        )

                 && 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes"

    )

VAR MeetsBothRequirements =

    CALCULATETABLE(

        VALUES( 'BPMS LOF Report'[CUID] ),

        MeetsFirstRequirement,

        'BPMS LOF Report'[TASK_STATUS] = "Closed",

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Partner Acknowledgement"

        )

    )

RETURN MeetsBothRequirements 

Now written as measures:

Total To Book = 
var tab=CALCULATETABLE(values('BPMS LOF Report'[CID]),
ALL('BPMS LOF Report'),
'BPMS LOF Report'[TASK]="Pre Engagement Process",
'BPMS LOF Report'[TASK_STATUS]="Closed",
'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith","Will Smith","Juan Valdes"})
return calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),all('BPMS LOF Report'),'BPMS LOF Report'[CID] in tab)

Entities Booked = 
calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),
       all('BPMS LOF Report'),
       'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith","Will Smith","Juan Valdes"},
       'BPMS LOF Report'[TASK_STATUS] = "Closed",
       CONTAINSSTRING('BPMS LOF Report'[TASK],"Start Partner Engagement") || CONTAINSSTRING('BPMS LOF Report'[TASK],"Partner Acknowledgement"))

Entities TBC = 
calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),
       all('BPMS LOF Report'),
       'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith","Will Smith","Juan Valdes"},
       'BPMS LOF Report'[TASK_STATUS] = "Closed" && CONTAINSSTRING('BPMS LOF Report'[TASK],"Start Partner Engagement") 
          || 'BPMS LOF Report'[TASK_STATUS] = "Received" && CONTAINSSTRING('BPMS LOF Report'[TASK],"Partner Acknowledgement"))

see attached

romovaro
Responsive Resident
Responsive Resident

Thank you very much Ibendin. It works.

 

Just a quick change For Entities to be confirmed I need to have

TASK = Start Partner Engagement and Task_Status = Closed by the Pre engagement Team

&&

TASK= Partner acknowledgement and Task_Status=Received

 

I tried to update your formula adding this extra field but not working. Could you have a look below at the 2 formulas below?

Entities TBC2 =
calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),
all('BPMS LOF Report'),
'BPMS LOF Report'[TASKACTUALPERFORMER] in {{"Will Smith","John SMith","Juan valdes"},
'BPMS LOF Report'[TASK_STATUS] IN {"Closed","Received"},
CONTAINSSTRING ('BPMS LOF Report'[TASK] IN {"Start Partner Engagement","Partner Acknowledgement"}
 
Entities TBC3 =
calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),
all('BPMS LOF Report'),
'BPMS LOF Report'[TASKACTUALPERFORMER] in {"Will Smith","John SMith","Juan valdes"},
'BPMS LOF Report'[TASK_STATUS] = "closed",
CONTAINSSTRING('BPMS LOF Report'[TASK],"Start Partner Engagement") && 'BPMS LOF Report'[TASK_STATUS] = "Received",CONTAINSSTRING('BPMS LOF Report'[TASK],"Partner Acknowledgement"))

"For Entities to be confirmed I need to have

TASK = Start Partner Engagement and Task_Status = Closed by the Pre engagement Team

&&

TASK= Partner acknowledgement and Task_Status=Received"

 

That makes no logical sense.  Did you mean to say 

 

 

 

TASK = Start Partner Engagement && Task_Status = Closed by the Pre engagement Team

||

TASK= Partner acknowledgement && Task_Status=Received

romovaro
Responsive Resident
Responsive Resident

Hi IBendin

 

Sorry for my explanations. Customer goes through diferent stages,.."Pre engagement Process"...... "Start Partner engagement"...."Partner acknowledgement"...etc.

 

the pre engagement team for this example is: WIll Smith, John SMith and Juan Valdes.

 

Entities to be booked: total of CUID where the task containing "Start Partner engagement" was closed (Task_status = Closed) by the pre engagement team (TASKACTUALPERFORMER=WIll Smith, John SMith and Juan Valdes) and the task partner acknowledgement is Closed.

NOTE: (Doesn't matter is the task "Partner acknoeldgement" was closed by the pre engagement team or not...just needs to show CLosed in the Task_Status

 

Entities to be confirmed: total of CUID where the task containing "Start Partner engagement" was closed (Task_status = Closed) by the pre engagement team (TASKACTUALPERFORMER=WIll Smith, John SMith and Juan Valdes) and the task partner acknowledgement is Received.

NOTE: (Doesn't matter is the task "Partner acknoeldgement" is received by the pre engagement team or not...just needs to show Received in the Task_Status

NOTE: (Doesn't matter is the task "Partner acknoeldgement" was closed by the pre engagement team or not...just needs to show CLosed in the Task_Status

 

If it doesn't matter then the logic check should not be included.

 

"if A doesn't matter and B = 1"    is the same as  "if B = 1".

 

You may want to spend time cleaning up your logic rules.

romovaro
Responsive Resident
Responsive Resident

Hi Ibendin

 

I think both A and B matters. I think the formula I used at the beg of the post explains the requirements.

 

FIrst requirement istotal of CUID where the task containing "Start Partner engagement" was closed (Task_status = Closed) by the pre engagement team (TASKACTUALPERFORMER=WIll Smith, John SMith and Juan Valdes) (that should be the part in the formula highlighted in red)

 

Second requirement: Once we have all the CUIDs from n the first requirement, we check the CUID column to see CUIDs with the task "Partner acknoledgement" Closed (that should be the part in the formula highlighted in blue)

 

I beleive my formula is missing something after....RETURN MeetsBothRequirements 

 

Entities Booked =

VAR MeetsFirstRequirement =

    CALCULATETABLE(

        VALUES('BPMS LOF Report'[CUID] ),

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Start Partner Engagement"

            && 'BPMS LOF Report'[TASK_STATUS] = "Closed"

        )

            && 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes"

    )

VAR MeetsBothRequirements =

    CALCULATETABLE(

        VALUES( 'BPMS LOF Report'[CUID] ),

        MeetsFirstRequirement,

        'BPMS LOF Report'[TASK_STATUS] = "Closed",

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Partner Acknowledgement"

        )

    )

RETURN MeetsBothRequirements 

 

 

 

Hope this explains better the situation.  

 

lbendlin
Super User
Super User

Your sample does not contain a CUID column or table. Please update/expand. 

romovaro
Responsive Resident
Responsive Resident

Hi Ibendin

 

It's the last Column in the table

 

romovaro_0-1646574982493.png

 

Ah, sorry, it didn't show on my browser. 

 

 "I need to use the CID column and then Intersect with the CUID column" is not very clear to me.

What is the expected outcome based on the sample data?

 

This piece of code is likely incorrect:

 FILTER (

            'BPMS LOF Report',

            'BPMS LOF Report'[TASK] = "Pre Engagement Process"

                && 'BPMS LOF Report'[TASK_STATUS]= "Closed"

                 && 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes"

    )

It should likely be 

 FILTER (

            'BPMS LOF Report',

            'BPMS LOF Report'[TASK] = "Pre Engagement Process"

                && 'BPMS LOF Report'[TASK_STATUS]= "Closed"

                 && ('BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes")

    )

Remember that AND operations have a higher order than OR operations.

You can also rewrite the variable like this:

 

var tab =   CALCULATETABLE(
        VALUES('BPMS LOF Report'[CID]),
        'BPMS LOF Report'[TASK] = "Pre Engagement Process",
        'BPMS LOF Report'[TASK_STATUS]= "Closed",
        'BPMS LOF Report'[TASKACTUALPERFORMER] IN { "John Smith", "Will Smith","Juan Valdes"}
    )
romovaro
Responsive Resident
Responsive Resident

Hi Ibendin

 

During the "Pre engagement process" , CUID are not yet assigned. Only CID number. 

CID is a unique customer number and CUID is used as entity level. (CID could be Microsoft and CUID is Microsoft Spain, Microsoft Germany, Microsoft Colombia, etc.)

romovaro_1-1646579205406.png

 

 

 

What I am trying to acheive with the formula is...

 

1 step= Find all the CID that have Task = Pre Engagement Process // Task_status=Closed and Taskactualperformer = John Smith, Will SMith or Juan Valdes

 

Once I have this requirement , I want the formula to return the CUID that have CID = 1 step

 

Example in the table above:

 

CID 1000583 has pre Engagement Process Closed and performer is John SMith (requirements checked)

return: IF we check CID column and intersect with the CUID column, we see that CID 1000583 have unique CUIDs (trying to use distinccount in the formula and blank not included) = 

1000583MY01

1000583BE01

 

Formula That i tried:

Total To Book2 =

var tab =

    CALCULATETABLE(

        VALUES('BPMS LOF Report'[CID]),

        FILTER (

            'BPMS LOF Report',

            'BPMS LOF Report'[TASK] = "Pre Engagement Process"

                && 'BPMS LOF Report'[TASK_STATUS]= "Closed"

                 && 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes"

    )

    return

    CALCULATE(

        DISTINCTCOUNT('BPMS LOF Report'[CUID]),

        INTERSECT(VALUES('BPMS LOF Report'[CID]), tab),

        FILTER (

        'BPMS LOF Report',

        CONTAINSSTRING ( 'BPMS LOF Report'[TASK], "Pre Engagement" )

            && 'BPMS LOF Report'[TASK_STATUS] = "Closed"

    )

)

Here is a calculated column for Total to Book. Let me know if this is what you are going for.

 

 

Total to Book = 
var tab=CALCULATETABLE(values('BPMS LOF Report'[CID]),
ALL('BPMS LOF Report'),
'BPMS LOF Report'[TASK]="Pre Engagement Process",
'BPMS LOF Report'[TASK_STATUS]="Closed",
'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith","Will Smith","Juan Valdes"})
return calculate(COUNTROWS(values('BPMS LOF Report'[CUID])),all('BPMS LOF Report'),tab)

 

Sample attached.

romovaro
Responsive Resident
Responsive Resident

Hello Ibendlin,

 

thanks for your help. Just quick question regarding your formula...I see that your "To Book Column" is 26 with the Sample in the report. But unique CUID are only 2.

 

romovaro_0-1646642319176.png

 

To count unique CUID values and "not blank" i updated your formula with the "DISTINCTCOUNTNOBLANK formula. what do you think?

Total To Book = var tab =CALCULATETABLE(values('BPMS LOF Report'[CID]), ALL('BPMS LOF Report'), 'BPMS LOF Report'[TASK]="Pre Engagement Process", 'BPMS LOF Report'[TASK_STATUS]="Closed", 'BPMS LOF Report'[TASKACTUALPERFORMER] in {"John Smith", "Will Smith", "Juan Valdes"}) return calculate(DISTINCTCOUNTNOBLANK(('BPMS LOF Report'[CUID])),all('BPMS LOF Report'),'BPMS LOF Report'[CID] in tab)

 

Could you help me with the other 2 pls? It's the same formula...one when task that contains "Partner acknoledgement" and is Closed and the other one when contains "Partner acknoledgement" and is Received

 

Entities booked: total number CUIDs where prep team closed "start partner engagement" task and "Partner Ackn" is closed

 

I tried the formula below but something is wrong. I guess is the last part "RETURN MeetsBothRequirements "...

Entities Booked =

VAR MeetsFirstRequirement =

    CALCULATETABLE(

        VALUES('BPMS LOF Report'[CUID] ),

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Start Partner Engagement"

            && 'BPMS LOF Report'[TASK_STATUS] = "Closed"

        )

                 && 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"

            || 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan Valdes"

    )

VAR MeetsBothRequirements =

    CALCULATETABLE(

        VALUES( 'BPMS LOF Report'[CUID] ),

        MeetsFirstRequirement,

        'BPMS LOF Report'[TASK_STATUS] = "Closed",

        CONTAINSSTRING(

            'BPMS LOF Report'[TASK],

            "Partner Acknowledgement"

        )

    )

RETURN MeetsBothRequirements 

romovaro
Responsive Resident
Responsive Resident

Another try in the formula.
But I get the error: A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.
 
Entities Booked =
var tab =
CALCULATETABLE (
VALUES ( 'BPMS LOF Report'[CUID] ),
FILTER (
'BPMS LOF Report',
'BPMS LOF Report'[TASK_STATUS] = "Closed"
&& CONTAINSSTRING ( 'BPMS LOF Report'[TASK], "Partner Engagement" )
)
&& 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Will Smith"
|| 'BPMS LOF Report'[TASKACTUALPERFORMER] = "John Smith"
|| 'BPMS LOF Report'[TASKACTUALPERFORMER] = "Juan valdes"
)
return
CALCULATE (
COUNT ( 'BPMS LOF Report'[CUID]),
INTERSECT ( VALUES('BPMS LOF Report'[CUID]), tab ),
FILTER (
'BPMS LOF Report',
'BPMS LOF Report'[TASK_STATUS] = "Closed"
&& CONTAINSSTRING ( 'BPMS LOF Report'[TASK], "Partner Acknowledgement")
)
)

A couple of notes:

- I mentioned that my proposal used calculated columns. If you look at the raw data you will see that the result is 2. Change to a measure or use your aggregation as needed.

- please check again how I wrote the code. It avoids the exact issue you are facing with the other two queries. Rewrite them accordingly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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