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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BobKoenen
Helper IV
Helper IV

Calculated Column Dax based on multiple variables to get total subscription value

Hi You all,

 

I am trying to create a column in DAX which gives me the total value of a subscription and I know what I want but not how to do it. I hope you can help me. My data looks like this:

 

CustomerValueStart dateEnd DateBilling interval Desired column of total value
A1001-1-202031-11-2020Month1100
B251-1-202031-12-20204 weekly325
C50001-6-202030-6-2020Incidental5000
D15001-4-202031-12-2020Quarterly4500

 

Sow i need a formula that depending on the Billing interval

Month = Difference in months between start date and End date * value

4 week = (Difference in Weeks between start date and End date/4 ) * Value

Incidental = value

Quarterly = Difference in quarters between start date and End Date * Value

 

I hope you can help me. 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi  @BobKoenen 

You could create a column as below:

Result = SWITCH('Table'[Billing interval ],
"Month",'Table'[Value]*(DATEDIFF('Table'[Start date],'Table'[End Date],MONTH)+1),
"4 weekly",'Table'[Value]*INT(DIVIDE((DATEDIFF('Table'[Start date],'Table'[End Date],DAY)+1),7*4)),
"Incidental",'Table'[Value],
"Quarterly",'Table'[Value]*(DATEDIFF('Table'[Start date],'Table'[End Date],QUARTER)+1))

Result:

3.JPG

 

And here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi  @BobKoenen 

You could create a column as below:

Result = SWITCH('Table'[Billing interval ],
"Month",'Table'[Value]*(DATEDIFF('Table'[Start date],'Table'[End Date],MONTH)+1),
"4 weekly",'Table'[Value]*INT(DIVIDE((DATEDIFF('Table'[Start date],'Table'[End Date],DAY)+1),7*4)),
"Incidental",'Table'[Value],
"Quarterly",'Table'[Value]*(DATEDIFF('Table'[Start date],'Table'[End Date],QUARTER)+1))

Result:

3.JPG

 

And here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@BobKoenen , Create a new column like.  Change logic as per need

new column =
var _diff = datediff([start date], [end date],day)
return
switch( true(),
[Billing interval] ="Incidental", [value],
[Billing interval] ="weekly", [value]*_diff/4,
[value]*_diff
)

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.