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

Adjustment of a Formula

Goodday,

 

I need an adjustment of a working formula

 

% Actief Provider A = Divide(SUM('Table'[Aantal Provider A]);(sum('Table'[Aantal Actief])))
 
This formula now calculates the number of subscriptions Provider A has and devides it with the total amount of subscriptions.
In this example Provider A has 2 different cariers Operator A and Operator B
 
So basically i need to update my formula so that it takes in a account the amount of subscriptions provider A has with Carrier A
The formula should be something like
 
% Actief Provider A = Divide(SUM('Table'[Aantal Provider A] with'Table' [Carrier A));(sum('Table'[Aantal Actief])))
 
Provider A   Carier A
Provider A   Carier B
Provider A   Carier B
Provider A   Carier A
Provider A   Carier A
6 REPLIES 6
v-lili6-msft
Community Support
Community Support

HI, @RvdHeijden

You could use Calculate Function to evaluate an expression in a context that is modified by the specified filters.

like:

% Actief Provider A = Divide(Calculate(SUM('Table'[Aantal Provider A]), filter('Table', 'Table' [Carrier]="Carrier")),(sum('Table'[Aantal Actief])))

 

For example:

result = DIVIDE(CALCULATE( SUM('Table'[Qty]),FILTER('Table','Table'[Carier]="Carier A")),SUM('Table'[Qty]))

8.JPG

 

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lili6-msft

 

Lin, that might be a step in the right direction but we are not quite there yet.

It first has to filter in 2 different collumns in another table called 'EFOS' so basically IF a records is from Provider A and Carrier A then it should Add them up first and then devide it by the total amount of active users.

 

Something like this:

% Actief Provider A = Divide(calculate(SUM('Table'[Aantal Actief]);Filter('EFOS';'EFOS'[Carrier]="Carrier A";'EFOS'[provider]= Provider A)));(sum('Table'[Aantal Actief])))
 
This formula obviously doesnt work but its about this part in blue

hi, @RvdHeijden

For two or more conditionals in the formula, you should use “&&” or AND() in it.

For example

 

% Actief Provider A =
DIVIDE (
    CALCULATE (
        SUM ( 'Table'[Aantal Actief] ),
        FILTER (
            'EFOS',
            'EFOS'[Carrier] = "Carrier A"
                && 'EFOS'[provider] = "Provider A"
        )
    ),
    SUM ( 'Table'[Aantal Actief] )
)

 

or

 

% Actief Provider A =
DIVIDE (
    CALCULATE (
        SUM ( 'Table'[Aantal Actief] ),
        FILTER (
            'EFOS',
            AND ( 'EFOS'[Carrier] = "Carrier A", 'EFOS'[provider] = "Provider A" )
        )
    ),
    SUM ( 'Table'[Aantal Actief] )
)

 

By the way, EFOS'[provider]= Provider A,Provider A is a text, and should be "Provider A"

 

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lili6-msft and @ryan_mayu

In both examples the returned outcome is 100% and that is not possible because this provider has 2 carriers so it shouldn't be 100%

hi, @RvdHeijden

Please check:

1. if "Table" has created a relationship with "EFOS"

2. Use ALL/ ALLEXCEPT/ ALLSELECTED in your formula like below:

(here is a blog for you as a reference:

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept...  )

% Actief Provider A =
DIVIDE (
    CALCULATE (
        SUM ( 'Table'[Aantal Actief] ),
        FILTER (
            'EFOS',
            AND ( 'EFOS'[Carrier] = "Carrier A", 'EFOS'[provider] = "Provider A" )
        )
    ),
   CALCULATE (

     SUM ( 'Table'[Aantal Actief] ), ALL('EFOS'[Carrier],  'EFOS'[provider]))
)

 

If not your case, please share a sample pbix file or some data sample and expected output.  Do mask sensitive data before uploading.

 

 

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@RvdHeijden

 

 

% Actief Provider A = Divide(calculate(SUM('Table'[Aantal Actief]);Filter('EFOS';'EFOS'[Carrier]="Carrier A"&&'EFOS'[provider]= Provider A)));(sum('Table'[Aantal Actief])))
 
Please see the coding in red and try the new one.
 
Thanks




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.