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
haraldjw
Frequent Visitor

Result same period last year is correct for the subtotal, but sometimes blank in details

Who can help me with the following problem?

 

The formula 'Result same period last year' gives correct values for the subtotal, but details are blank for those rows where the result for this year is blank.

 

DAX-formula:

Resultaat vorig jaar = CALCULATE(sum('FACT-GrootboekMutaties'[Bedrag])*-1,'DIM-Grootboek'[GrootboekType]="P",SAMEPERIODLASTYEAR('DIM-Kalender'[Date]))

 

For example:

  • Subtotal        1.000
  • Fuel        500
  • Tax        300

 

When asking for the 'Result this year' while filtering last year, it shows the correct results.

 

  • Subtotal        1.000
  • Fuel        500
  • Tax        300
  • Lease        200

 

Thanks for your help!

7 REPLIES 7
V-pazhen-msft
Community Support
Community Support

@haraldjw 

You should not include calculation in the expression (*-1), put it outside the calculate function like below.

 

Resultaat vorig jaar = CALCULATE(sum('FACT-GrootboekMutaties'[Bedrag]),'DIM-Grootboek'[GrootboekType]="P",SAMEPERIODLASTYEAR('DIM-Kalender'[Date]))*-1)

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

VijayP
Super User
Super User

@haraldjw 

Instead of using 'DIM-Grootboek'[GrootboekType]="P" as an internal filter context , remove that and use as an external and see whehter it works! I am thinking the issue with Internal Filter context!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


@VijayP @Thanks for your help. I even removed the filter but it makes no difference.

 

I can't find out why the totals are shown correct, and individuals lines are empty, only when the result of this year is empty. 

amitchandak
Super User
Super User

@haraldjw , Please make sure calendar table is marked as date table

 

also Try

Resultaat vorig jaar = CALCULATE(sum('FACT-GrootboekMutaties'[Bedrag])*-1,'DIM-Grootboek'[GrootboekType]="P",dateadd('DIM-Kalender'[Date],-1,year))

@amitchandak The calender is marked as date table (of course).

 

The strange thing is: Why are the subtotals correct? And those details missing where the value of this year is blank?

@haraldjw , very difficult to tell without looking at data.Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

@amitchandak I appreciate your help! Can you send me a PB where to send the file?

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.