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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors