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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ERing
Helper V
Helper V

Add column that is = (Spend/Days in month)

I'm struggling to accomplish my need with DAX so I thought I'd give a Power Query solution a try.
 
My table looks like below. My goal is to add a column where the result for each row is = (monthly spend / days in month).
 
So for each row in April, I'd like to show $16.67 ($500/ 30 days in April) and for each row in May I'd like to show $12.90 ($400/31 days in May).
 
Anyone know how this can be done?

Capture.PNG


1 REPLY 1
jennratten
Super User
Super User

Hello - this is how you can do it.

 

jennratten_0-1693598037432.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdK7DcAgEATRXoiRYBfwpxbk/tuwnHonneiebvcus6m5e5RaVu/lqV9yppFpZlqZjkxnpivTnUkdGtwvAAgEAoLAIEAIFAKGwGFwmP4ADoPD4DA4DA6Dw+AwOEY4Vs5p/eb0vA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Monthly Spend" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Monthly Spend", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "DaysInMonth", each Date.DaysInMonth([Date]), Int64.Type),
    #"Inserted Division" = Table.AddColumn(#"Added Custom", "Daily Spend", each [Monthly Spend] / [DaysInMonth], Currency.Type)
in
    #"Inserted Division"

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors