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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
datafan
Helper I
Helper I

Display previous month of row values without summarization

Hi Gurus!

 

In my fact table I have many row entries for customers with order dates and the products ordered.

Columns in consideration are:

'Sales'[Customer#]

'Sales'[ProductName]

'Sales'[OrderDate]

'Sales'[Price]

The OrderDate is  related to the dates table.

I have a filter YYYY-MM that I use to select the rows.

There is a field YYYY-MM  in the dates table, so no worries there.

In visual one I display all rows from the fact table that satisfy the filtered YYYY-MM.

I set the [Price] to not summarize so all rows are currently being displayed in visual one.

All is good.

 

In visual "ONE" I would like to display the rows where the 'Sales'[OrderDate]  is equal to the previous YYYY-MM. 

I realize that the visual will have rows that have the current YYYY-MM and  rows with the previous YYYY-MM.

I prefer to not require the user to enter two  YYYY-MMs in the filter visual.

 

I tried to use the CALCULATE formula but it only takes an aggregated parameter and the dateadd -1 month.

To get around my problem I was also thinking of a 2nd visual and dedicate a  second filter to visual "TWO" but that is an added visual taking up extra space.

 

Can you provide the function to display the rows that satisfy the previous month user selected  YYYY-MM in visual one?

 

Thanks!

 

 

3 REPLIES 3
amitchandak
Super User
Super User

@datafan , Not very clear , You can use time intelligence with Date

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

New column  or

Month Rank = RANKX(all('Date'),'Date'[Month Start date],,ASC,Dense)

 

Measure

This Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

I may have been unclear.

Please let me amend my request to make it clearer:

 

Here is my Sample Fact Table

Row| Date                |CustomerID | Product  |Qty  |Price  |Sales

1       |1/1/2021      |Cust1              |X1                 |1      |100      |   $100

2       |1/1/2021       |Cust2              |X1                 |2      |100      |   $200

3       |1/1/2021      |Cust3              |X2                  |1      |300      |   $300

4       |2/1/2021      |Cus1                |Y1                  |1      |500      |   $500

5       |2/1/2021      |Cus21             |P2                  |3      |100      |   $300

6       |3/1/2021      |Cus1                |PY                  |1      |20         |   $20

7      |4/1/2021       |Cust2               |XX                |3     |10          |   $30

 

There is a YYYY-MM filter that is in a Dates table and is related to the Date column in the Fact Table and the  user checks YYYY-MM = 2021-03

 

I would like Visual "A"  to display:

Row  |Date                |CustomerID | Product  |Qty  |Price  |Sales

6         |3/1/2021      |Cus1                |PY                  |1      |20         |   $20

 

I would like Visual "B"  to display the Previous Months records:

Row  |Date                |CustomerID | Product  |Qty  |Price  |Sales

4       |2/1/2021      |Cus1                |Y1                  |1      |500      |   $500

5       |2/1/2021      |Cus21             |P2                  |3      |100      |   $300

 

How to attain Visual "B"  display  that works off  only one filter, the one where the user selects 2021-03?

 

Hope this clarifies my request. 

Thanks in advance guys!

 

Fact Sales Table

 

Cust|Product|Qty|ItemPrice|TotalSale

1|

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Kudoed Authors