The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello Everyone,
I've been reading some threads about how to emulate loop in a measure and tried to apply them to my model, but haven't been able to, I'm still struggling a bit to understand with where am I going to do the +1.
Goal
To create a cumulative measure that adds all the operations that exceed 43 per hour in selected time frame (in two dimensions) between 2 selected dates and between 9am to 10pm.
The model
It's a big data base in excel, that contains per register:
Airline name, date of operation, passengers, capacity of aircraft, a support column that I created with a unitary value representing operation, etc.
Iv'e created a couple of support tables to manage time and date:
a) Date Table:
The Measure
So far I can get the exceeding number of operations per hour but still can't get it to be cummulative:
a) Working Measure (only exceeding ops in earliest selected hour and day):
@Cr1s88 , Have separate date and time table , joined to date part and time part of your date
Date part = datevalue([Datetime])
Time Part = Timevalue([Datetime])
Join them with respective dim
then have measures like
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])),
filter(Time, Time[Time] > time(9,0,0) && Time[Time] < time(22,0,0) ) )
or
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date]))
, filter(Time, Time[Time] > time(9,0,0) && Time[Time] < time(22,0,0) ) )
You can have only hour table if needed
Time Table
https://kohera.be/power-bi/how-to-create-a-time-table-in-power-bi-in-a-few-simple-steps/
https://radacad.com/script-for-creating-time-table-in-power-bi-with-hours-minutes-and-seconds-bucket...
Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
Hi Amitchandak, thank you so much for your input.
I'm looking at the idea and i could try to join my date and time table but still I'm missing the cumulative part that exceeds the 43 per hour.
If I understood right your measure proposals:
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date]))
, filter(Time, Time[Time] > time(9,0,0) && Time[Time] < time(22,0,0) ) )
This will sum all the operations (in this case sales) between dates and specified times, but I only need to sum per hour the exceeding 43 operations:
If 10am has 60 operations I need to sum = 60- 43 = 17
If 11 am has 40 operations I don't sum anything but keep the 17 and so on.
So far I can calculate exceeding operations in selected hour, now i just need to start making the sum of those values.
Thanks again for dedicating me some of your time.
Regards.