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

Create a measure that can be filtered

Hi guys, I have a question. I want to create an insight using a table like this (in a far more complex model):

 

ClientProductProduct TypeMonthly hoursStart dateEnd date
Client AOnline AdvertisingAdvertising401/01/201804/01/2018
Client BOnline AdvertisingAdvertising501/01/201801/01/2020
Client CWebsite MaintenanceService503/01/201801/01/2020
Client DOnline AdvertisingAdvertising304/01/201801/01/2020
Client DWebsite MaintenanceService209/01/201801/01/2020

 

I want to create a visual, preferably a column graph, that shows me the total monthly hours each month for selected dates (by slicer). I also have a Client key table with a slicer, so I want to be able to filter this graph based on client, so that clicking the Client slicer shows me the monthly hours for only this client. A client can have multiple products, and they can change between months.

 

I have a hard time getting there, because the data is using start and end dates, and so when plotting total monthly hours the model only shows them in the month where they start (because start date is linked to a calender date). I somehow need to make the model understand that these monthly hours return every month between the start and end date. They can change between months (a client can choose to buy more products) and I only want to be able to visualize this BY MONTH. 

 

I probably need to create a table within the measure and calculate my totals there, so it can be filtered on client. But I'm not sure how to get there.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User


Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User


Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


@ 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!:
The Definitive Guide to Power Query (M)

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

Hi Greg,

 

Many thanks for your suggestion. I wrote a measure similar to your periodic billing suggestion. It still only counts the monthly hours in their first month, but they are recurring hours. So to simplify my question; 

 

Client buys 10 hours each month starting february 1st. They stop buying hours before the start of april. The data only contains:

  

ClientMonthly hoursStart dateEnd date
Client A401/01/201803/31/2018

 

Total amount of hours bought is 12 (4 hours for jan, feb and march) and I want my visual to show only when I set my date selector on february or march.

 

Hope this clarifies.

Assuming a disconnected date table, you probably want something along the lines of:

 

Measure = 
VAR __month = MAX('Calendar'[Month])
VAR __start = MONTH(MAX('Table'[Start Date]))
VAR __end = MONTH(MAX('Table'[End Date]))
RETURN
IF(__month >= __start && __month <= __end,MAX('Table'[Monthly hours]),BLANK())

@ 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!:
The Definitive Guide to Power Query (M)

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

Thanks again, I will try this later. Why do I need to use a disconnected date table? This means that there must be no relationship between the date table and the data table I'm trying to analyze, correct?

Anonymous
Not applicable

Disconnecting the date table was the solution. Your periodic billing formula worked. Many thanks for your suggestion!

Awesome! Glad I could help!


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors