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
RvdHeijden
Post Prodigy
Post Prodigy

What am i doing wrong

Hello,

 

Im a DAX newbie but have a background in Excell and in Excell i would have figured out this problem in minutes but in DAX it already cost me a couple of days because they way formules are written is very different from in excel.

 

My problem is as follows.

 

I want to calculate a % from total 'Orders' (stagename) devided by the SUM of 4 'Stagenames' such as below

i already know this formule is wrong but im not sure what i am doing wrong.

 

But like i said im a beginner so it's probably something simple (at least i hope so)

 

2016-10-19_1100.png

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Scoringskans =
DIVIDE (
    CALCULATE ( COUNTROWS ( Project ); Project[StageName] = "Order" );
    CALCULATE (
        COUNTROWS ( Project );
        Project[StageName] = "Order"
            || Project[StageName] = "Lost Order"
            || Project[StageName] = "Bid Made"
            || Project[StageName] = "Prospect"
    )
)

 

Capture.PNG

 

 

Take note that in my example I have 1 line for "Other" which I don't include in my formula so I have 6/12 = 0,5 which is correct.

View solution in original post

14 REPLIES 14
Anonymous
Not applicable

Capture.PNG

 

Sorry... this formula works !

 

Scoringskans = CALCULATE(DIVIDE(DISTINCTCOUNT(Project[StageName]);COUNTROWS(Project));Project[StageName]="Order" || Project[StageName]="Prospect" || Project[StageName]="Lost Order" || Project[StageName]="Bid Made")

 

the || represent the OR function

 

@Anonymous

It still doesn't work because now it show almost in all cells 100% and some are empty because they have a status <> the ones in the formula.

The meaning was to calculate the total sum of all 'Orders' devided by all the customers I made a bid. So if i have 5 orders but made 100 bids then i have a 5% order rate

 

In this formula im missing the part where it counts all the rows with the status 'Order'

Anonymous
Not applicable

For that you need 2 CALCULATIONS functions in your formula AND not count distinct...

 

 

ScoringskansORDERS.vs.BIDSMADE RATIO = DIVIDE(CALCULATE(COUNTROWS(Project[StageName]);Project[StageName] = "Orders"));CALCULATE(COUNTROWS(Project));Project[StageName]= Project[StageName]="Bid Made")

@Anonymous

I think we are almost so thanks for your time and help but there im missing a couple of values in the formula.

 

ScoringsKans2 = DIVIDE(CALCULATE(COUNTROWS(Project[Stagename]);Project[Stagename] = "order";CALCULATE(COUNTROWS(Project));Project[StageName]"Lost Order"||Project[StageName]="Bid made"||Project[StageName]="Order"||Project[StageName]="Prospect")

 

Simply put i want to calculate #Orders / (SUM(#Lost Orders+#Bid made+#Order+#Prospect)

Anonymous
Not applicable

Scoringskans =
DIVIDE (
    CALCULATE ( COUNTROWS ( Project ); Project[StageName] = "Order" );
    CALCULATE (
        COUNTROWS ( Project );
        Project[StageName] = "Order"
            || Project[StageName] = "Lost Order"
            || Project[StageName] = "Bid Made"
            || Project[StageName] = "Prospect"
    )
)

 

Capture.PNG

 

 

Take note that in my example I have 1 line for "Other" which I don't include in my formula so I have 6/12 = 0,5 which is correct.

@Anonymous

Thank you, this works and it reads a 40,58 % change on an order

@Anonymous

Correction because im not sure if im missing that column. it's just that i have only 2 values now....it's either 100% or BLANK

Anonymous
Not applicable

Had similar problems when going from Excel to DAX. As soon as you figure out the CALCULATE function you're like a newly set free bird from a cage.

 

your measure = CALCULATE ( DIVIDE ( DISTINCTCOUNT ( 'tableNAME'[tableCOLUMN] ) ; COUNTROWS ( 'tableNAME' ) ) ; Project[StageName] = "Order" ; Project[StageName] = "YOUR CRITERIA(S)" )

 

Bon apetit

How do u set the different kinds of criteria's ? are the devided bij ; or , ?

 

Scoringskans = CALCULATE( Divide (Distinctcount (Project[StageName]) ; countrows (Project));Project[StageName] = "Order";Project[StageName]="Lost Order" && "Bid Made" && "Order" && "Prospect")))))

 

This way doesn't seem to work or i made a mistake somewhere

 

Anonymous
Not applicable

How many unique identities do you have in StageName column ?

 

If they are for example 5, then you just have to exclude the one you don't want in your calculation with

Project[StageName] <> "ID YOU DONT WANT"

 

Otherwise... for your 4 filtered ID's...

 

This should work

 

Scoringskans = CALCULATE( Divide (DISTINCTCOUNT(Project[StageName]) ; COUNTROWS (Project));Project[StageName] = "Order";Project[StageName]="Lost Order" ; Project[StageName]="Bid Made" ; Project[StageName]= "Order" ;Project[StageName]= "Prospect")

Bokazoit
Post Patron
Post Patron

CALCULATE is a multi-parameter function. You need to say

 

=CALCULATE(DISTINCT(Project[Stagename]);Project[Stagename] = "ORDER")/(CALCULATE(COUNT(Project[Stagename]);Project[Stagename] ="xxx")+CALCULATE(COUNT(Project[Stagename]);Project[Stagename] ="xxx")+CALCULATE(COUNT(Project[Stagename]);Project[Stagename] ="xxx")+CALCULATE(COUNT(Project[Stagename]);Project[Stagename] ="xxx"))

@Bokazoit

Apparently your formule doesn't work either however there is a bigger chance that i did something wrong.

Can you tell me what it is ?

 

ScoringsKans2 = CALCULATE(DISTINCT(Project[Stagename]);Project[Stagename] = "ORDER")/(CALCULATE(COUNT(Project[Stagename]);Project[Stagename] ="Lost Order")+CALCULATE(COUNT(Project[Stagename]);Project[Stagename] ="Order")+CALCULATE(COUNT(Project[Stagename]);Project[Stagename] ="Prospect")+CALCULATE(COUNT(Project[Stagename]);Project[Stagename] ="Bid Made"))

 

The error reads: "The function COUNT takes an argument that evaluates to numbers or dates and cannot work with values of type String."

It says that the Count function will not work with string type. I used the function I put in here on my own data with a ProductId which is a number. Try to convert the stagename to an id, and I am pretty sure it will work 🙂

Anonymous
Not applicable

COUNT doesn't count string types of cells. Instead use COUNTA

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.