cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
KellyLen Regular Visitor
Regular Visitor

New measure

Hi,

 

How should the DAX look like if I would like to create measure with following information:

image.png

 

Used columns are:

  • OK/NOK
  • Status

And values are Amount in EUR. 

 

I would like to calculate the percentage, where the formula is like Status: 1. Execution / Overall Total. For example 28 250 083,14 / 36 057 104,09 = ... 

 

Could you please help me with this?

 

Best regards,

Kelly 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Re: New measure

Hi @KellyLen,

 

Based on your table try to use this measure:

percentage = 

    IF (
        DISTINCTCOUNT ( 'Status'[Status] ) > 1 ,
        1 ,
        IF (
            DIVIDE (
                CALCULATE (
                    SUM ( 'Status'[Amount in EUR] ),
                    'Status'[Status] = VALUES ( 'Status'[Status] )
                ),
                CALCULATE ( SUM ( 'Status'[Amount in EUR] ), ALL ( 'Status'[Status],'Status'[NOK/OK] ) )
            )
                = BLANK (),
            0 ,
            DIVIDE (
                CALCULATE (
                    SUM ( 'Status'[Amount in EUR] ),
                    'Status'[Status] = VALUES ( 'Status'[Status] )
                ),
                CALCULATE ( SUM ( 'Status'[Amount in EUR] ), ALL ( 'Status'[Status],'Status'[NOK/OK] ) )
            )
        )
    )

Then format as % and you should get the result below (put it as table to be more visible).

 

per.png

 

 

If you need to take out only the Ok status and remove the NOK from the calculation

 

percentage =
IF (
    MAX ( 'Status'[NOK/OK] ) = "NOK",
    BLANK (),
    IF (
        DISTINCTCOUNT ( 'Status'[Status] ) > 1,
        1,
        IF (
            DIVIDE (
                CALCULATE (
                    SUM ( 'Status'[Amount in EUR] ),
                    'Status'[Status] = VALUES ( 'Status'[Status] )
                ),
                CALCULATE ( SUM ( 'Status'[Amount in EUR] ), ALL ( 'Status'[Status] ) )
            )
                = BLANK (),
            0,
            DIVIDE (
                CALCULATE (
                    SUM ( 'Status'[Amount in EUR] ),
                    'Status'[Status] = VALUES ( 'Status'[Status] )
                ),
                CALCULATE ( SUM ( 'Status'[Amount in EUR] ), ALL ( 'Status'[Status] ) )
            )
        )
    )
)

percent.png

 

Total calculations can also be redone to not include NOK

 

Regards,

MFelix

 

 

 


Regards

Miguel Felix


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

Proud to be a Datanaut!




View solution in original post

20 REPLIES 20
Microsoft v-yulgu-msft
Microsoft

Re: New measure

Hi @KellyLen,

 

Suppose your table structure is like below:

1.PNG

 

Create a measure and add it into Matrix visual.

Percentage =
DIVIDE (
    MAX ( 'New Measure'[Amount] ),
    CALCULATE (
        SUM ( 'New Measure'[Amount] ),
        ALLEXCEPT ( 'New Measure', 'New Measure'[Category] )
    )
)

2.PNG

 

Best regards,

Yuliana Gu

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

Re: New measure

Hi,

 

Actually all the types that have value are OK and rows that do not have type are NOK.  I have not got currency in different column, I just have the amounts already in EUR. So the table is like this:
image.png

 

 

The result you got, seems to be the one I would like to get, but I do not understand the formula you created. And the result definitely has to be in percentage already. 

 

KellyLen Regular Visitor
Regular Visitor

Re: New measure

Is there anyone that could help me? I would like to know more about creating measures, but I do not understand the logic of it. 

Super User III
Super User III

Re: New measure

Hi @KellyLen,

 

Based on your table try to use this measure:

percentage = 

    IF (
        DISTINCTCOUNT ( 'Status'[Status] ) > 1 ,
        1 ,
        IF (
            DIVIDE (
                CALCULATE (
                    SUM ( 'Status'[Amount in EUR] ),
                    'Status'[Status] = VALUES ( 'Status'[Status] )
                ),
                CALCULATE ( SUM ( 'Status'[Amount in EUR] ), ALL ( 'Status'[Status],'Status'[NOK/OK] ) )
            )
                = BLANK (),
            0 ,
            DIVIDE (
                CALCULATE (
                    SUM ( 'Status'[Amount in EUR] ),
                    'Status'[Status] = VALUES ( 'Status'[Status] )
                ),
                CALCULATE ( SUM ( 'Status'[Amount in EUR] ), ALL ( 'Status'[Status],'Status'[NOK/OK] ) )
            )
        )
    )

Then format as % and you should get the result below (put it as table to be more visible).

 

per.png

 

 

If you need to take out only the Ok status and remove the NOK from the calculation

 

percentage =
IF (
    MAX ( 'Status'[NOK/OK] ) = "NOK",
    BLANK (),
    IF (
        DISTINCTCOUNT ( 'Status'[Status] ) > 1,
        1,
        IF (
            DIVIDE (
                CALCULATE (
                    SUM ( 'Status'[Amount in EUR] ),
                    'Status'[Status] = VALUES ( 'Status'[Status] )
                ),
                CALCULATE ( SUM ( 'Status'[Amount in EUR] ), ALL ( 'Status'[Status] ) )
            )
                = BLANK (),
            0,
            DIVIDE (
                CALCULATE (
                    SUM ( 'Status'[Amount in EUR] ),
                    'Status'[Status] = VALUES ( 'Status'[Status] )
                ),
                CALCULATE ( SUM ( 'Status'[Amount in EUR] ), ALL ( 'Status'[Status] ) )
            )
        )
    )
)

percent.png

 

Total calculations can also be redone to not include NOK

 

Regards,

MFelix

 

 

 


Regards

Miguel Felix


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

Proud to be a Datanaut!




View solution in original post

KellyLen Regular Visitor
Regular Visitor

Re: New measure

Hi,

 

Actually, I would need the total calculation be based on statuses totals as well.
The hole visual looks actually like this:

image.png

 

I do not know, if the subcategory there changes anything. I did not noticed to add this at first. 😕

Super User III
Super User III

Re: New measure

I just made a change ot my answer please check it.


Regards

Miguel Felix


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

Proud to be a Datanaut!




KellyLen Regular Visitor
Regular Visitor

Re: New measure

Thank you so much! It really worked! 🙂 

 

Kelly 

KellyLen Regular Visitor
Regular Visitor

Re: New measure

Hi again,

 

How to make an easier calculation, where I should only calculate percentage of OK/Grand total? 

 

Best regards,

Kelly 

Super User III
Super User III

Re: New measure

Hi @KellyLen,

 

Not sure of what you want to calculate can you give an example please.

 

Regards,

MFelix


Regards

Miguel Felix


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

Proud to be a Datanaut!




Helpful resources

Announcements
Coming Soon: T-Shirt Design Contest

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors