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

Dynamic Filtering from Table - Period of time

Hi!! hope you can help me! 🙂 

 

I want to create a slicer which filters with the "User Selection" column from the following table called 'Slicer Period Table'

 

auxilio99357_1-1619478425138.png

 

When the user selects Last Month, Last Qtr or Last Yr, the value that i want to get are the ones in the column "Month index", so i created this measure:

 

Period Selection = IF (HASONEVALUE ('Slicer Periodo Table'[User Selection]),VALUES('Slicer Period Table'[Month Index]),COUNTROWS(DimDates))
 

Then I want to calculate some measures that are filter by this slicer, like this:

 

Total Revenue = CALCULATE([Revenue], ALL(DimDates), AND(DimDates[month index]<=0, DimDates[month index]>= [Period Selection]))
 
The problem is that the measure gives the followig error: "A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed." 
i´m very new to DAX so i don´t know how to solve it.
 
Unfortunately i cannot take pictures of my Data tables but i have a common sales table with every transaction that has this 4 columns:
auxilio99357_3-1619479616273.png

I will always have the amount of sales up to two months before the current day. (For example if we are on April 2021, the last sales I have are from February 2020). Thats why the month index in the 'Slicer Period Table' don´t make sense.

 

 

And a DimDates table like this
auxilio99357_2-1619479278512.png
 
Thank you!!!! 😊

 

 

 

1 ACCEPTED SOLUTION
samdthompson
Memorable Member
Memorable Member

Hello, yes you can do this. Heres a link to a very detailed description which I have used lots of time. Its even got a downloadable example.

 

https://blog.crossjoin.co.uk/2016/05/30/creating-current-day-week-month-and-year-reports-in-power-bi...

 

 

// if this is a solution please mark as such. Kudos always appreciated.

View solution in original post

1 REPLY 1
samdthompson
Memorable Member
Memorable Member

Hello, yes you can do this. Heres a link to a very detailed description which I have used lots of time. Its even got a downloadable example.

 

https://blog.crossjoin.co.uk/2016/05/30/creating-current-day-week-month-and-year-reports-in-power-bi...

 

 

// if this is a solution please mark as such. Kudos always appreciated.

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.