Forum Discussion

sandrasanchez's avatar
sandrasanchez
Advocate I
10 years ago

countrows only selected

Hi!

I'm trying to create a calculated column with a value (Invoice Discount) divided by the number of rowsç

this is my dax function:

 

Importe1 = calculate(max(InvoiceSet[Invoice Discount]);ALLSELECTED(InvoiceSet)) / CALCULATE(COUNTROWS(InvoiceSet);ALLSELECTED(InvoiceSet))

This is my matrix and the solution would be 20/ 15 

Invoice discount = 20 and the number of rows is 15

with a measure it works but I want it to be a column and the result is not as I hope (1.33, Importe 1 is 1.12)

¿Any idea?

Thanks so much!!!!! :smileyhappy:

 

12 Replies

    • sandrasanchez's avatar
      sandrasanchez
      Advocate I

      Hi Adolfo,

      Thank you very much for answering me , but I'm not able to sendo an email, and in your linkedin you haven't your mail published, so I can't contact with you,

      thank you any way

      • waltheed's avatar
        waltheed
        Impactful Individual

        It would indeed be very helpful if you could share your pbix file.

        For instance via OneDrive, share the file, and paste the link here.

    • sdjensen's avatar
      sdjensen
      Solution Sage

      I just cheched out your model. You should calculate Importe1 as a measure not as a calculated column in your table.

  • Baskar's avatar
    Baskar
    Resident Rockstar

    Hey Buddy
    You have problem with your data modelling or Table Relationship. Please check on this. whenever u getting the same value mean u have prob with your Relationship.

  • Hi sdjensen:

    if I put it as a measure it works, but I want it to be a column to be able to discount Importe1 so importe would be:

    Importe = Importe - Importe 1

    Thanks so much for helping me!! ;)

    • wonga's avatar
      wonga
      Continued Contributor

      sandrasanchez

       

      I'm unable to modify anything in "Edit Queries" in your pbix file. Looks like it uses an external data source. Is it possible for you to import the data into the PBIX file so it doesn't rely on connecting to an external data source?

       

      Since you want a calculated column, that means Power Query (M) must be used.

      • sandrasanchez's avatar
        sandrasanchez
        Advocate I

        I have imported the data from external source (Dynamics CRM), you should be able to modify it....

        sorry if you can't

    • sdjensen's avatar
      sdjensen
      Solution Sage

      Why do you want it as a calculated column?? You should be able to obtain the same just with an extra measure defined as Importe - Importe 1.

       

      If you want this new measure to be called Importe then you need to find a new name for the current called Importe.

  • If I do Importe as a measure as you say, when I put a KPI with this value it doesn't summarize correctly unless it is a column that's why I want it to be a column, is not any way of doing it being a column??

    thanks so much!!