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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
lboldrino
Resolver I
Resolver I

SOS : Difference cost day by day (Expect Weeknend and holiday)

neHey.

I need your help, as soos as possible:

hier ist my table

Date-stingDateCostCostdifference by day
01.-01.10.01.10.20211 519 995,92 
01.-04.10.04.10.20213 759 429,15 
01.-05.10.05.10.20215 912 983,88 
01.-06.10.06.10.20218 681 894,87 
01.-07.10.07.10.202111 334 598,81 
01.-10.10.10.10.202114 416 893,77 
01.-11.10.11.10.202117 317 876,87 
01.-12.10.12.10.202120 114 197,38 
01.-13.10.13.10.202123 326 011,89 
01.-14.10.14.10.202126 045 726,91 
01.-15.10.15.10.202128 475 989,33 
01.-18.10.18.10.202131 775 465,70 
01.-19.10.19.10.202134 655 781,70 

i need to calcute, my cost myday - (myday-1)

 

i try this, but its not correct. and for weekend and holidays haven't any cost.

in mondays, ist thePreviousDay Friday.

 

 

 

 

Day-1_Global = 

VAR _globalPreviousDay =  CALCULATE (
        SUM ( DeliveryDetails[Global]),
        FILTER (
             DeliveryDetails,
             DeliveryDetails[DeliveryDatum]
                = EARLIER ( [DeliveryDatum] ) - 1
              ))
        
    
RETURN DeliveryDetails[Global] - _globalPreviousDay

 

 

 

please help me. 😞

i must finished this tomorrow.

best regarsd 🙂

1 ACCEPTED SOLUTION

@lboldrino Incorrect that it is incorrect. 🙂 Worked for me. Are you dates really dates or text? See attached PBIX.

 

 



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
lboldrino
Resolver I
Resolver I

@Greg_Deckler : you are the Best!

Done. I rebuild my table in M Query and your solution is correct ! 

thanX a lot 🙂

lboldrino
Resolver I
Resolver I

Please any Idea?? 😐

Greg_Deckler
Super User
Super User

@lboldrino See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler :

sorry but nor correct. 

__PreviousDate is correct,
__Previous ist nor correct -> current - __Previous not correct
 
lboldrino_1-1634817727278.png

 

any idea??? 
here is the code, i try only with  __Previous & its not correct:
 

 

 

 

 

 

 

Day-1_Global = 
  VAR __Current = [Global]
  VAR __PreviousDate = MAXX(FILTER(DeliveryDetails,DeliveryDetails[DeliveryDatum] < EARLIER(DeliveryDetails[DeliveryDatum] )),DeliveryDetails[DeliveryDatum] )

  VAR __Previous = MAXX(FILTER(DeliveryDetails,[DeliveryDatum]=__PreviousDate),[Global])
RETURN
 __Previous
--  __Current - __Previous

 

 

 

 

 

 

 

i will to have this result:

Date-stingDateCostCostdifference by day
01.-01.10.01.10.20211 519 995,921 519 995,92
01.-04.10.04.10.20213 759 429,152 239 433,23
01.-05.10.05.10.20215 912 983,882 153 554,72
01.-06.10.06.10.20218 681 894,872 768 911,00
01.-07.10.07.10.202111 334 598,812 652 703,93
01.-10.10.10.10.202114 416 893,773 082 294,96
01.-11.10.11.10.202117 317 876,872 900 983,11
01.-12.10.12.10.202120 114 197,382 796 320,51
01.-13.10.13.10.202123 326 011,893 211 814,51
01.-14.10.14.10.202126 045 726,912 719 715,02
01.-15.10.15.10.202128 475 989,332 430 262,42
01.-18.10.18.10.202131 775 465,703 299 476,37
01.-19.10.19.10.202134 655 781,702 880 316,00

 

 

 

 

@lboldrino Incorrect that it is incorrect. 🙂 Worked for me. Are you dates really dates or text? See attached PBIX.

 

 



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler : 😪

lboldrino_0-1634823418515.png

its a date-col but my table is a union table 😞

what can i do? 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.