Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sandrasanchez
Advocate I
Advocate I

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!!!!! Smiley Happy

Captura.PNG

 

12 REPLIES 12
sandrasanchez
Advocate I
Advocate I

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!!

sandrasanchez
Advocate I
Advocate I

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!! 😉

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.

/sdjensen
wonga
Continued Contributor
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.

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

sorry if you can't

Baskar
Resident Rockstar
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.

sandrasanchez
Advocate I
Advocate I

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

/sdjensen
sandrasanchez
Advocate I
Advocate I

I have uploaded to onedrive

https://onedrive.live.com/?id=root&cid=CF098846A6E4E947

It's the document Ejemplo number of rows

I hope it works

Thanks so much!!!!

asocorro
Skilled Sharer
Skilled Sharer

Can you provide the .pbix file?

Connect with me in LinkedIn: https://pr.linkedin.com/in/adolfosocorro
Follow me on Twitter: https://twitter.com/AdolfoSocorro

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

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.

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.