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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nj17
Helper III
Helper III

Previous year sales variance measure not working on MTD/YTD slicer

Hi,

 

I have created a Daily/MTD/YTD slicer by using below formula

 

MTD/YTD Selection =

 VAR TodayDate = TODAY()

VAR YesterDay = TODAY() - 1

 VAR YearStart = CALCULATE(STARTOFYEAR('Fact Store'[transaction date]),YEAR('Fact Store'[transaction date]) = YEAR(TodayDate))

VAR MonthStart = CALCULATE(STARTOFMONTH('Fact Store'[transaction date]),YEAR('Fact Store'[transaction date]) = YEAR(TodayDate),MONTH('Fact Store'[transaction date]) = MONTH(TodayDate))

VAR Result =

UNION (

  ADDCOLUMNS (

        CALENDAR(YesterDay,TodayDate),

"Selection","Yesterday"

),

ADDCOLUMNS (

        CALENDAR(MonthStart,TodayDate),

"Selection","MTD"

),

ADDCOLUMNS (

        CALENDAR(YearStart,TodayDate),

"Selection","YTD"

)

)

RETURN

Result
 
and it is appearing in report as below but when I select Any item
from this slicer then vPY is not getting filtered and it remain constant.How can I make this work
vPY =
Sales Amount vPY = IFERROR(CALCULATE(IF([Sales Amount PY]=0,"-",  SUM('Fact Store'[Amount]) -[Sales Amount PY])/[Sales Amount PY]),"-")
Sales Amount PY = CALCULATE(SUM('Fact Store'[Amount]),SAMEPERIODLASTYEAR('Dim Date'[Date]))
nj17_1-1669113024023.png

 Thank you,

nj

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

Hi @nj17 ,

 

It is not possible to reproduce this issue at the moment. Can you provide the relevant test data(with sensitive information removed) and screenshots of the expected results, so that I can answer them for you as soon as possible.
link:
How to provide sample data in the Power BI Forum - Microsoft Power BI Community
How to Get Your Question Answered Quickly - Microsoft Power BI Community

 

Looking forward to your feedback.


Best Regards,

Henry

Hi @v-henryk-mstf 

Please find the link where i uploaded my file

https://www.dropbox.com/s/2lz9mbcdyq67rno/test.pbix?dl=0

When I select Year from slicer ,values are filtering

nj17_0-1669569794204.png

when I select below filter from mtd ytd slicer then no value appear for both the measures

nj17_1-1669569951335.png

taging for help @Ashish_Mathur @Jihwan_Kim @amitchandak 

 

thanks

nj

I have not opened your file.  For your YTD measure to work, a year should definitely be selected.


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

Hi @v-henryk-mstf 

 

Till I share the sample data can you please share how can i create measures which give me variance of current year and last year sales and it should change by [Yesterday,WTD,MTD,YTD] and also by [Year,Month,Day]

the measure vPY is previous year variance

nj17_0-1669488683008.png

thank you

nj

could anyone help?

@v-henryk-mstf @amitchandak @Greg_Deckler 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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