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

Calculate shipment frequency with a variable for 2022

Hi everyone ! 

 

I am having a problem calculating my shipping frequency.

I have a database that starts from 2018 to today and I would like to know how many days a shipment takes place.

 

Example for 2021 I calculated it like this: 

Shipment frequency 2021 = iferror(CALCULATE(365/DISTINCTCOUNT(Database[Descrip.of Shipment]), FILTER(Database, Database[CurrShipmentStart].[Année]=2021)),BLANK()) 

 

And for 2022 = 

Shipment frequency 2022 = iferror(
CALCULATE(DATEDIFF(DATE(2022,01,01),TODAY(),DAY)
/
DISTINCTCOUNT(Database[Descrip.of Shipment]), FILTER(Database, Database[CurrShipmentStart].[Année]=2022))
,BLANK())
 
I would like to have a single measure to put it in a matrix which would allow me, for the years 2018 until 2021 to divide the number of days in the year by the distinct count of the descrip.of.shipment and for the current year, divide the number of days between the 1st day of the year until today by the descrip.of.shipment.
 
How would I realize this measure?
 
Thanks a lot.
 
Ilias
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try a measure like

divide(datediff(min(Database[CurrShipmentStart]), max(Database[CurrShipmentStart]), day), DISTINCTCOUNT(Database[Descrip.of Shipment]))

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hello, 

 

Thank you for your answer. 

It works 🙂

 

amitchandak
Super User
Super User

@Anonymous , Try a measure like

divide(datediff(min(Database[CurrShipmentStart]), max(Database[CurrShipmentStart]), day), DISTINCTCOUNT(Database[Descrip.of Shipment]))

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.