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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
spartan27244
Resolver I
Resolver I

Period in time for % calculations

I have a date table used as a slicer for the the user and looks like

PeriodName, PeriodDate, PeriodKey

2019, 1/1/2019, 20191/1/2019

....

2019, 12/31/2019, 201912/31/2019

2020, 1/1/2020, 20201/1/2020

...

2020, 12/31/2020, 202012/31/2020

 

The PeriodKey Relates to a table containing the numbers for which I would like to get the % From. 

PeriodKey, Value

20191/1/2019, 23

20193/30/2019, 19

....

20202/23/2020, 40

20204/23/2020, 45

 

I want to be able to get the Sum of the Value field based on the Period that the user has selected i.e.

if selected 2019 I should see 23+19 = 42, regardless of any other filters that may be applied. i.e. not other filters are allowed except the PeriodName

 

I have tried this but it did not work.

Calculate(Sum('pbi pmd'[mm]), Allexcept('pbi vwCustomerReportPeriods', 'pbi vwCustomerReportPeriods'[PeriodName]))

which works exactly like

Sum('pbi pmd'[mm])

When other filters are applied.

2 REPLIES 2
spartan27244
Resolver I
Resolver I

Matbe it would help if I posted a pic of the model, The report period is in the 'pbi vwCustomerReportPeriods' table and the slicer field is PeriodName. The table I want to sum is 'pbi PMD' and the Column is MM, as you can see the 2 tables are related by PBI_RptPeriodKey, in the current setting, this actually works in the contex that I can add filters such as Spouse, Male, Female, etc. ant the calculation is correct, but I cannot explain why.

 

MMPeriod = Calculate(Sum('pbi pmd'[mm]), allexcept('pbi PMD', 'pbi PMD'[MM]))

 

spartan27244_0-1620233612515.png

 

Greg_Deckler
Community Champion
Community Champion

@spartan27244 Maybe:

Period Sum = 
  VAR __Period = SELECTEDVALUE('Date Table'[PeriodName])
  VAR __Table = FILTER('Table containing the numbers',LEFT([PeriodKey])=__Period)
RETURN
  SUMX(__Table,[Value])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.