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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
swarajyadav24
New Member

Error while selecting alternate Quarters from Date slicer

I have Year, Month-Name, Date and Quarter-Name columns in Dim_Cal Table.

I have used below DAX to get the value of previous period
----------------------------------------

Sales-Previous-Year=
Var Current= CALCULATE(SUM(Fact_ETB[Sales]) )
Var P-Y= CALCULATE(SUM(Fact_ETB[Sales]), SAMEPERIODLASTYEAR(Dim_Cal[Date]) )
Var Result= Current-P-Y
return Result
----------------------------------------

Now, I have dragged Year, Quarter-Name and Month-Name under one slicer lets name it "Time"

I have taken a KPI and Dragged Sales-Previous-Year measure in it. It is showing values correctly when I select continoues
records under Time Slicer(like Q1 and Q2). However, When I select Q1 and Q4 under any same or any year. It is throwing me error. on the KPI Visual, when I click on the "see details" on the KPI Visual. it show's the below error.  

 

swarajyadav24_0-1711634105393.png

 

 

Now using Sales-Previous-Year measure provide me dax, such that even though I select alternate options in Time slicer.
the error should skip instead of getting error I should get some other text(like "The selected columns Not applicable" or 0) 

1 ACCEPTED SOLUTION

Hi @swarajyadav24 ,

 

Perhaps you could try the EDATE function:

EDATE function (DAX) - DAX | Microsoft Learn

 

Best regards,
Community Support Team_ Scott Chang

View solution in original post

3 REPLIES 3
swarajyadav24
New Member

Thank you for the quick response. 

Do we have any other DAX function, which will provide same result as SAMEPERIODLASTYEAR does, At the same time, it should also work, when we click (Q1 and Q3) or (Q2 and Q4). 

 

 

Hi @swarajyadav24 ,

 

Perhaps you could try the EDATE function:

EDATE function (DAX) - DAX | Microsoft Learn

 

Best regards,
Community Support Team_ Scott Chang

v-tianyich-msft
Community Support
Community Support

Hi @swarajyadav24 ,

 

When you use SAMEPERIODLASTYEAR, the date table needs to be continuous.

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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