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
varung8899
Helper II
Helper II

How to return sum of values when multiple INT values are selected in slicer and calculate LY-1 value

Hello, can you please help for below 2 queries.
1.) I have Year & YYYYMM slicers. How can I show the sum of sales for last year-1 when I select Year & YYYYMM in slicers. Year is single select & YYYYMM is multi select. If I chose 2024 in Year and 202401, 202402 in YYYYMM, I need the KPI card LY measure to show value for Year 2022 & YYYYMM IN 202201, 202202 depending on how many YYYYMM I select from the slicer. I have date, Year, YYYYMM, YYYYMM-1, YYYYMM-2 columns in dim_calendar table. Using SAMPERIODLASTYEAR function I have calculated sales for last year but I need Lastyear - 1 sales for the same period. Data below. 
2.) I am unable to capture the values especially when multiple YYYYMM integer values are selected. When I create a measure I am unable to use VALUES and IN functions since the measure allows only 1 value as output. How to capture selected values in slicer and pass it to a variable or a table.

varung8899_0-1742307075952.png

 




1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1742356960756.png

 

 

Jihwan_Kim_0-1742356887897.png

 

Sales: = 
SUM( sales[sales] )

 

Previous Year Sales: = 
CALCULATE([Sales:], SAMEPERIODLASTYEAR('calendar'[Date]))

 

Previous Year - 1 Sales: = 
CALCULATE([Previous Year Sales:], SAMEPERIODLASTYEAR('calendar'[Date]))

 

Selected period sales: = 
VAR _selectedlist =
    VALUES ( 'calendar'[YearMonth] )
RETURN
    CALCULATE (
        [Sales:],
        FILTER ( ALL ( 'calendar' ), 'calendar'[YearMonth] IN _selectedlist )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

5 REPLIES 5
v-venuppu
Community Support
Community Support

Hi @varung8899 ,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please accept it as a solution and give it a 'Kudos' so other community members with similar problems can find a solution faster.

Thank you.

Regards,

Rama U.

v-venuppu
Community Support
Community Support

Hi @varung8899 ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

Regards,

Rama U.

v-venuppu
Community Support
Community Support

Hi @varung8899 ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

Regards,

Rama U.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1742356960756.png

 

 

Jihwan_Kim_0-1742356887897.png

 

Sales: = 
SUM( sales[sales] )

 

Previous Year Sales: = 
CALCULATE([Sales:], SAMEPERIODLASTYEAR('calendar'[Date]))

 

Previous Year - 1 Sales: = 
CALCULATE([Previous Year Sales:], SAMEPERIODLASTYEAR('calendar'[Date]))

 

Selected period sales: = 
VAR _selectedlist =
    VALUES ( 'calendar'[YearMonth] )
RETURN
    CALCULATE (
        [Sales:],
        FILTER ( ALL ( 'calendar' ), 'calendar'[YearMonth] IN _selectedlist )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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