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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Help with previous day calculation

I am trying to create the below visual;

 

Griffy_0-1593100423488.png

 

I have implemented this DAX, and it will not bring back the correct figures?

Total Installs Yesterday - iOS = CALCULATE([Total Installs],dateadd(DateDimension[Date],-1,DAY))

Total Installs Previous Day - iOS = CALCULATE([Total Installs],dateadd(DateDimension[Date],-2,DAY))

I have even tried the below;

 

Yesterday iOS = CALCULATE(SUM('iOS - App Units'[Installations]),PREVIOUSDAY('iOS - All App Units'[Date]))

I ahve tried with both a Dimdate and the date in the table.

And this also comes back with the incorrect number, I have a visual with the total installs with a filter on it so I know what figure I should be getting back;

 

Griffy_0-1593101711078.png

 

 

Thanks

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I assume that you want to calculated the installs yesterday and the installs the day before yesterday. I created data to reproduce your scenario.

Table:

i1.PNG

 

You may create measures as below.

Yesterday = 
CALCULATE(
    SUM('Table'[Installs]),
    FILTER(
        ALLSELECTED('Table'),
        'Table'[Date]=TODAY()-1
    )
)

The day before yesterday = 
CALCULATE(
    SUM('Table'[Installs]),
    FILTER(
        ALLSELECTED('Table'),
        'Table'[Date]=TODAY()-2
    )
)

 

Today is 6/26/2020. Here is the result:

i2.PNG

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I assume that you want to calculated the installs yesterday and the installs the day before yesterday. I created data to reproduce your scenario.

Table:

i1.PNG

 

You may create measures as below.

Yesterday = 
CALCULATE(
    SUM('Table'[Installs]),
    FILTER(
        ALLSELECTED('Table'),
        'Table'[Date]=TODAY()-1
    )
)

The day before yesterday = 
CALCULATE(
    SUM('Table'[Installs]),
    FILTER(
        ALLSELECTED('Table'),
        'Table'[Date]=TODAY()-2
    )
)

 

Today is 6/26/2020. Here is the result:

i2.PNG

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Great thanks for this @v-alq-msft ,

 

Really helped me out

aj1973
Community Champion
Community Champion

Hi @Anonymous 

This formula is not correct Yesterday iOS = CALCULATE(SUM('iOS - App Units'[Installations]),PREVIOUSDAY('iOS - All App Units'[Date])): PREVIOUSDAY  Function works better with your DateDimension Table.

 

Did you create a Day Column in your DateDimension Table? if yes then try using PREVIOUSDAY function in your other 2 measures instead of DATEADD!

 

Maybe a Dummy Pibx file could help better understand your issue.

 

Regards

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

amitchandak
Super User
Super User

@Anonymous , Do with Date table only.

Mark your date dimension as date table.

 

Check does date has timestamp. Change datatype to datetime, choose a format to see time. If it has time then create date column join that with date table

 

New date = Table[Date].Date

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.