Forum Discussion

PeterBI's avatar
PeterBI
Helper I
8 years ago
Solved

Creating and Using Measures in this Example

Hello,

 

I just started with PowerBI and need a little Help in creating measures and using it in a view.

I have the following Table with a relation to the datekey Table and the Idea for the view.

 

So my first question is the creation of the measure to calculate the WinnerQuote and the second question is using it to calculate the view for the weekly and the monthly numbers.

 

Thanks for an Idea for the Solution,

Peter

 

PBIX File

Excel File

 

 

 

 

  • Hi PeterBI,

     

    First of all I just complicated the measure a lot just use this and it works perfectly good:

    WinnerQuote =
    DIVIDE (
        CALCULATE ( COUNT ( Winner[Winner] ), Winner[Winner] = 1 ),
        CALCULATE ( COUNT ( Winner[Winner] ) )
    )

    Just being hard because of a different problem I had before.

     

    Regarding the setup of the table here is the full menu copy:

     

    Regards,

    MFelix

7 Replies

  • Hi PeterBI,

     

    First of all don't know if your example in the Excel is based on the values you have in your PBIX file but add this measure:

     

    WinnerQuote =
    VAR WeekValue =
        MIN ( DateKey[Week] )
    RETURN
        IF (
            MAX ( DateKey[Week] ) = WeekValue,
            DIVIDE (
                CALCULATE ( COUNT ( Winner[Winner] ), Winner[Winner] = 1 ),
                CALCULATE ( COUNT ( Winner[Winner] ), DateKey[Week] = WeekValue )
            ),
            DIVIDE (
                CALCULATE ( COUNT ( Winner[Winner] ), Winner[Winner] = 1 ),
                CALCULATE ( COUNT ( Winner[Winner] ), DateKey[Week] = DateKey[Week] )
            )
        )

     

    The result is as follow:

     

     

     

    regards,

    MFelix

     

    • PeterBI's avatar
      PeterBI
      Helper I

      Hi MFelix,

       

      Thank You Very much. Is it possible to post a screenshot from the Visu Menue where you configure the Table?

       

      Kind Regards

      Peter

      • MFelix's avatar
        MFelix
        Super User

        Hi PeterBI,

         

        First of all I just complicated the measure a lot just use this and it works perfectly good:

        WinnerQuote =
        DIVIDE (
            CALCULATE ( COUNT ( Winner[Winner] ), Winner[Winner] = 1 ),
            CALCULATE ( COUNT ( Winner[Winner] ) )
        )

        Just being hard because of a different problem I had before.

         

        Regarding the setup of the table here is the full menu copy:

         

        Regards,

        MFelix