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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

 

View solution in original post

v-zhouwen-msft
Community Support
Community Support

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
v-zhouwen-msft
Community Support
Community Support

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

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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