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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Chaucer
Helper II
Helper II

Measure Help

Hi,

 

I'm trying to create a couple of very basic measures, and for some reason the logic is escaping me.

 

I've got a very simple data table as follows:

 

OrderNoOrderDateParcelsEstDispatchDateActualDispatchDate
120/02/2022120/02/202220/02/2022
220/02/2022220/02/202221/02/2022
320/02/2022320/02/202222/02/2022
420/02/2022221/02/202222/02/2022
521/02/2022121/02/202222/02/2022
621/02/2022221/02/202222/02/2022
721/02/2022321/02/202223/02/2022
821/02/2022222/02/202223/02/2022
922/02/2022122/02/202223/02/2022
1022/02/2022222/02/202223/02/2022

 

No date table, no other tables.

 

What I want to do is knock up a graph that uses the order date as its X-axis, and plots the following on the Y.

Total No of parcels ordered by day.
Total No of parcels that should have dispatched on that date.*

Total No of parcels that actually dispatched on that date.*

Difference between est and actual.
Trailing 7 day averages of each.

 

It's the *'ed one's I 'm struggling to do. 
Any help gladly received.

4 REPLIES 4
Chaucer
Helper II
Helper II

I tried messing about with Filters using an EARLIER, but that didn't work either....

TestEst =
CALCULATE(
sum('Order Lines'[Parcels]),
Filter(ALL('Order Lines'),
COUNTROWS(Filter('Order Lines', 'Order Lines'[EstDispatchDate] = EARLIER('Order Lines'[Order Date])
)
)))

Hi, @Chaucer 

 

vjaneygmsft_0-1646035974859.png

These can be expressed by measure.

If you use measure, change 'EARLIER' to 'selectedvalue'. 

Like:

Total No of parcels ordered by day =
COUNTX (
    FILTER ( ALL ( table ), [OrderDate] = SELECTEDVALUE ( table[OrderDate] ) ),
    [OrderNo]
)

vjaneygmsft_1-1646036272105.png

But I don't know how you're going to put the two on a line chart and the logic of ’Trailing 7 day averages of each.‘

Can you explain it?

 

Best Regards,

Community Support Team _Janey

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

@Chaucer , One of the options is to create a date table and join all dates with that. One join will be active and the rest will be inactive, which you can use using userelationship

 

Last 7 days

Rolling 12 Sales =
var _max = maxx(allselcted(date),date[date]) // or today()
var _min = _max -7
return
CALCULATE(countrows(Table) ,filter(date, date[date] <=_max && date[date] >=_min))

 

Today =

CALCULATE(countrows(Table) ,filter(date, date[date] =today()) )

 

 

Yesterday=

CALCULATE(countrows(Table) ,filter(date, date[date] =today()) )

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

 

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in...

 

@amitchandak - is there any way of doing it without a date table? It's a Direct Query...

If it was excel, I would just use a sumif, ie. for EstDispatch, sum the number of parcels where EstDispatchDate=OrderDate ...


 

EstDispatches = CALCULATE(sum('Order Lines'[Parcels]), Filter('Order Lines', 'Order Lines'[EstDispatchDate] = 'Order Lines'[Order Date]))

The above measure nearly does, it, but just sums the parcels where EstDispatchDate=OrderDate...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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