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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
azaterol
Helper V
Helper V

Calculate previous Day together

Hello everyone,

 

I have a matrix with year, month and day. I would now like to see another subtotal displayed.

If possible, the intermediate result should be displayed above each day.

 

I've tried everything, I can't get any further.

 

Here is the measure used:

 

 

 

kaufende POS = COUNTROWS('Customers')

 

 

 

 

azaterol_0-1721742882768.png

 

Here is how I imagine it:

 

Subtotal 30
   
3 Mai 2024 24
   
Subtotal 12
   
2 Mai 2024 12

 

Here's the explanation as to why the subtotal is 30 after May 3rd: Because I only want to show one-time customers and not customers who have already purchased before. In other words, there are customers here who bought on May 2nd and also on May 3rd. Duplicates should not be counted twice.

 

If the rows are too complicated, I'm also happy with a new column. Just like the lines, this should add up the customers from the previous day and only calculate duplicates once.

If it's not possible, I would like to have the result as a column.


Thank you for any help.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@azaterol , if you are currently using one measure in matrix visual. You can use 2 and use option Switch values on rows.

 

the second measure can be a distinct count for the last 2 days. Prefer date table, joined with the date of your table

Rolling 2 = CALCULATE(distinctcount('Customers'[ID]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-2,day))

 

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

Anonymous
Not applicable

Hi @amitchandak ,thanks for the quick reply, I'll add more.

Hi @azaterol ,

The Table data is shown below:

vzhouwenmsft_1-1722233781731.png

Use the following DAX expression to create a measure

Measure2 =
VAR _currentDate =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _previousDate = _currentDate - 1
RETURN
    CALCULATE (
        COUNTROWS ( DISTINCT ( 'Table'[Member ID] ) ),
        ALL ( 'Table'[Date] ),
        'Table'[Date] >= _previousDate
            && 'Table'[Date] <= _currentDate
    )

Final output

vzhouwenmsft_2-1722233877981.png

 

Best Regards,
Wenbin Zhou

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @amitchandak ,thanks for the quick reply, I'll add more.

Hi @azaterol ,

The Table data is shown below:

vzhouwenmsft_1-1722233781731.png

Use the following DAX expression to create a measure

Measure2 =
VAR _currentDate =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _previousDate = _currentDate - 1
RETURN
    CALCULATE (
        COUNTROWS ( DISTINCT ( 'Table'[Member ID] ) ),
        ALL ( 'Table'[Date] ),
        'Table'[Date] >= _previousDate
            && 'Table'[Date] <= _currentDate
    )

Final output

vzhouwenmsft_2-1722233877981.png

 

Best Regards,
Wenbin Zhou

amitchandak
Super User
Super User

@azaterol , if you are currently using one measure in matrix visual. You can use 2 and use option Switch values on rows.

 

the second measure can be a distinct count for the last 2 days. Prefer date table, joined with the date of your table

Rolling 2 = CALCULATE(distinctcount('Customers'[ID]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-2,day))

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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