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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Mister_T
Advocate I
Advocate I

[DAX Measure] Correct values, but wrong total

Dear Community,

again, I am lost in the depth of Power BI and DAX. Any help greatly appreciated!


I have the following table 'Sales':

 

Deal ID

Deal Closed

Deal Won

Reseller

001

FALSE

FALSE

A

002

TRUE

FALSE

B

002

TRUE

FALSE

B

002

TRUE

FALSE

C

003

FALSE

FALSE

A

004

TRUE

FALSE

B

005

TRUE

TRUE

A

005

TRUE

TRUE

A

006

TRUE

TRUE

B

007

TRUE

FALSE

A

007

TRUE

FALSE

A

007

TRUE

FALSE

C

008

TRUE

FALSE

A

 

To find out, which reseller was involved in how many deals close lost, I have created the following measure (using help from this thread).

Please note: For one and the same deal (same Deal ID) it might happen, that

  • one reseller is listed several times --> then this reseller should only be counted once per deal
  • the deal is handled by more than one reseller --> then each of the resellers involved in the deal should be counted once
COUNT_Reseller_Lost = 
CALCULATE (
    DISTINCTCOUNT ( 'Sales'[Deal ID] ),
    FILTER (
        ALLEXCEPT ( 'Sales', 'Sales'[Reseller] ),
        'Sales'[Deal Closed] = TRUE ()
            && 'Sales'[Deal Won] = FALSE ()
        )
    )

 

This measure brings me the ring counts for each reseller, but unfortunately, the total is wrong!

Mister_T_0-1618571639803.png

How to I have to adjust the measure, that both the values for each Reseller and the Total are displayed correctly?

 

Thank you very much!

 

Mister_T

1 ACCEPTED SOLUTION
ERD
Super User
Super User

Hi @Mister_T ,

Create a second measure:

 

#Result = 
IF(HASONEVALUE('Sales'[Reseller]),
[COUNT_Reseller_Lost],
SUMX(VALUES('Sales'[Reseller]), [COUNT_Reseller_Lost])
)

 

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

6 REPLIES 6
ERD
Super User
Super User

Hi @Mister_T ,

Create a second measure:

 

#Result = 
IF(HASONEVALUE('Sales'[Reseller]),
[COUNT_Reseller_Lost],
SUMX(VALUES('Sales'[Reseller]), [COUNT_Reseller_Lost])
)

 

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Thank you @ERD!

 

Works like a charm! 🙂

Thanks again for your help! Greatly appreciated.

amitchandak
Super User
Super User

@Mister_T , Try

COUNT_Reseller_Lost =
CALCULATE (
DISTINCTCOUNT ( 'Sales'[Deal ID] ),
FILTER ('Sales' ,
coalesce(CALCULATE(Max('Sales'[Deal Closed]) , ALLEXCEPT ( 'Sales', 'Sales'[Deal ID] )), false()) =True(),
&& 'Sales'[Deal Won] = FALSE ()
)
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak,

 

Thank you very much!

Unfortunately, your DAX formula returns
"The syntax for '&&' is incorrect. (DAX(CALCULATE (DISTINCTCOUNT ( 'Sales'[Deal ID] ),FILTER ('Sales' ,coalesce(CALCULATE(Max('Sales'[Deal Closed]) , ALLEXCEPT ( 'Sales', 'Sales'[Deal ID] )), false()) =True(),&& 'Sales'[Deal Won] = FALSE ()))))."

 

Deleting the ',' after "TRUE ()",

 

COUNT_Reseller_Lost_NEW = 
CALCULATE (
    DISTINCTCOUNT ( 'Sales'[Deal ID] ),
    FILTER ('Sales' ,
        COALESCE (
            CALCULATE(
                Max('Sales'[Deal Closed]) ,
                ALLEXCEPT ( 'Sales', 'Sales'[Deal ID] )
                ),
            FALSE ()
            )
        =TRUE ()
        && 'Sales'[Deal Won] = FALSE ()
        )
    )

 


lets the formula pass as measure, but as soon as I want to use it in a vizual, I get the error message

Mister_T_0-1618575772544.png


Any alternative to 'MAX' when it cannot work with BOOLEAN?

Thanks a lot!

 

@Mister_T , Try like

COUNT_Reseller_Lost_NEW = CALCULATE ( DISTINCTCOUNT ( 'Sales'[Deal ID] ), FILTER ('Sales' , COALESCE ( CALCULATE( Count('Sales'[Deal Closed]), 'Sales'[Deal Closed] = TRue() , ALLEXCEPT ( 'Sales', 'Sales'[Deal ID] ) ), 0 ) <>0 && 'Sales'[Deal Won] = FALSE () ) )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you, @amitchandak! Your help is greatly appreciated.

Unfortunatelly, here again, I get an error message, when using this measure as value for a table (or any other) visual:

Mister_T_0-1618814070857.png


"The function COUNT cannot work with values of type Boolean."

 

Best regards,

 

Mister_T

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.