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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
powerbinewbie23
Frequent Visitor

Slicer Affecting Data, Get Selected Month Data and Last Year

Hi everyone, I'm having some trouble trying to create a total of the revenue from my dataset. I am looking to total the revenue for the slicer selected year and month, and then compare it with the previous year's same month revenue. Here is the DAX query I've run so far - 

 

Revenue This Year-Month =
CALCULATE(
    SUM('Append1'[qtdamount]),
    'Append1'[scenario] = "Actual",
    Append1[rollup_level_4_name]="Revenue")
 
Revenue Last Month = 
CALCULATE(
    SUM('Append1'[qtdamount]),
    'Append1'[scenario] = "Actual",
    'Append1'[rollup_level_4_name] = "Revenue",
    'Append1'[fiscalyear] = SELECTEDVALUE('Append1'[fiscalyear]) - 1,
    'Append1'[fiscalmonth] = SELECTEDVALUE('Append1'[fiscalmonth])
)
 
Revenue Last Month gives no value. Revenue This Year-Month has the fiscalmonth and fiscalyear selected by the user in a splicer. I don't have TI because the data is pulling from another software and I am not allowed to. Also the data is aggregated to month-level so it would cause problems if there was date level duplication? Not sure, but any advice on how to calculate last years same month, or next year's data will be super helpful - dataset is scrubbed and shrunk to relevant columns.
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @powerbinewbie23 

 

@Ashish_Mathur Thank you very much for your prompt reply. Allow me to offer a different approach here:

 

Your code seems to be fine, but if it is not outputting the expected results, then try the following code.

 

Here's some dummy data

 

“Append1”

vnuocmsft_0-1713753709279.png

 

Create measures.

 

 

Revenue This Year-Month = 
CALCULATE(
    SUM('Append1'[qtdamount]),
    FILTER('Append1',
    'Append1'[scenario] = "Actual" 
    &&
    Append1[rollup_level_4_name]="Revenue"
    )
)

 

 

 

Revenue Last Month = 
CALCULATE(
    SUM('Append1'[qtdamount]),
    FILTER(ALL('Append1'),
    'Append1'[scenario] = "Actual" 
    &&
    'Append1'[rollup_level_4_name] = "Revenue" 
    &&
    'Append1'[ficalyear] = MAX('Append1'[ficalyear]) - 1 
    &&
    'Append1'[ficalmonth] = MAX('Append1'[ficalmonth])
    )
)

 

 

Here is the result.

 

vnuocmsft_1-1713753933430.png

 

vnuocmsft_0-1713754261170.png

 

 

Regards,

Nono Chen

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

2 REPLIES 2
Anonymous
Not applicable

Hi @powerbinewbie23 

 

@Ashish_Mathur Thank you very much for your prompt reply. Allow me to offer a different approach here:

 

Your code seems to be fine, but if it is not outputting the expected results, then try the following code.

 

Here's some dummy data

 

“Append1”

vnuocmsft_0-1713753709279.png

 

Create measures.

 

 

Revenue This Year-Month = 
CALCULATE(
    SUM('Append1'[qtdamount]),
    FILTER('Append1',
    'Append1'[scenario] = "Actual" 
    &&
    Append1[rollup_level_4_name]="Revenue"
    )
)

 

 

 

Revenue Last Month = 
CALCULATE(
    SUM('Append1'[qtdamount]),
    FILTER(ALL('Append1'),
    'Append1'[scenario] = "Actual" 
    &&
    'Append1'[rollup_level_4_name] = "Revenue" 
    &&
    'Append1'[ficalyear] = MAX('Append1'[ficalyear]) - 1 
    &&
    'Append1'[ficalmonth] = MAX('Append1'[ficalmonth])
    )
)

 

 

Here is the result.

 

vnuocmsft_1-1713753933430.png

 

vnuocmsft_0-1713754261170.png

 

 

Regards,

Nono Chen

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

 

Ashish_Mathur
Super User
Super User

Hi,

Try this approach

  1. Create a Calendar Table with calculated column formulas for Year, Month name and Month number
  2. Sort the Month name column by the Month number
  3. Create a relationship (Many to One and Single) from the Date column of the Data Table to the Date column of the Calendar Table
  4. Create slicer for Year and Month and make a selection
  5. Write these measures
Revenue This Year-Month = CALCULATE(SUM('Append1'[qtdamount]),'Append1'[scenario] = "Actual",Append1[rollup_level_4_name]="Revenue")
Revenue in SPLY = calculate([Reenue this Year-Month],sameperiodlastyear(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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