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
Anonymous
Not applicable

Calculate cost per day

I have a basic dataset with monthly cost. It only has month and year as a date column, so to calculate cost per day I could to Cost per day = [Total Cost] / 30 (very crude) but this only works if I include the month in the visual.

Ideally I want to ensure that even if I am not using the month in the visual, I can show Cost per day without it aggregating up.

Also, ideally I want to use the appropriate days of the month. 

 

Any ideas?

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@Anonymous Really need sample data and a better understanding of the scenario. You can get the actual days in a month by constructing a DATE and then using EOMONTH with DAYS like the following (assuming your month is a numeric month:

DAY(EOMONTH(DATE([Year],[Month],1),0))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Anonymous
Not applicable

Hmm, you could create a measure, that counts the number of different months in your table.

If you include month in your table, it will return 1. If you only year in your table, it will return 12 (under the condition, that you have data in each month)

 

Now that you have the number of months, you can do: DailyCost= Divide(TotalCost, NumberOfMonths *30)

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hmm, you could create a measure, that counts the number of different months in your table.

If you include month in your table, it will return 1. If you only year in your table, it will return 12 (under the condition, that you have data in each month)

 

Now that you have the number of months, you can do: DailyCost= Divide(TotalCost, NumberOfMonths *30)

Greg_Deckler
Community Champion
Community Champion

@Anonymous Really need sample data and a better understanding of the scenario. You can get the actual days in a month by constructing a DATE and then using EOMONTH with DAYS like the following (assuming your month is a numeric month:

DAY(EOMONTH(DATE([Year],[Month],1),0))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks guys, actually both these solutions work for me. 

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.