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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ladislaocsulak
Frequent Visitor

DAX Measure not affected by slicer

Hello,

I would appreciate help with the next problem.

I created the following measure because I need the quantity of sales for the last 30 days.

 

sales_quantity_last_30_days = CALCULATE(DISTINCTCOUNT(sales[id]),DATESINPERIOD ( Calendario[Date], TODAY(), -30, DAY ))

 

The problem is that I have a slicer to filter the dates that worked fine if I used if I looked at the quantity of total sales (not just the last 30 days). But when using the created measure, it is not affected by the slicer.

And I would like the slicer to affect the measure created so that it shows sales for the previous 30 days based on the last day filtered in the slicer.

 

I upload a dummy table where I show the situation of my measurements and how the slicer affects the measure counting the total sales and not the other that counts just the last 30 days:

https://drive.google.com/drive/folders/1TOYezhAuiy0ADTNcKVL1ayNw5XoLMo_I?usp=sharing

 

 

Thanks in advance!

1 ACCEPTED SOLUTION
djurecicK2
Super User
Super User

Hi @ladislaocsulak ,

 Please try replacing TODAY() with MAX(Calendario[Date])

 

 

View solution in original post

4 REPLIES 4
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @ladislaocsulak 

Can you pleas try the following:

Formula =
var __Today = TODAY()
var __StartDay = __Today - 30

Return

CALCULATE(
   DISTINCTCOUNT(sales[id]),
   DATESBETWEEN ( Calendario[Date], __StartDay, __Today)
)

 

It could be that you need to calculate -29 isntead of -30 depending on your logic

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

This keeps the measure in the same way, without being affected by the slicer.

djurecicK2
Super User
Super User

Hi @ladislaocsulak ,

 Please try replacing TODAY() with MAX(Calendario[Date])

 

 

This worked. Thank you!

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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