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

LIMIT DATA SET IN IF FUNCTION USING DAX

Below DAX Function returns all the data in the dataset . How can I limit it to the IF conditions stated ?

Trial =

VAR _kpi = CALCULATE(SUM('RAN AH'[Daily]),'Date'[Date] = SELECTEDVALUE('DAY'[Time]))

VAR _allowed_dates = {MAX('Date'[Date]), MAX('Date'[Date]) - 1, MAX('Date'[Date]) -7, TODAY()}

RETURN

        IF(SELECTEDVALUE('DAY'[Time]) IN _allowed_dates, _kpi , BLANK())

 

desbarden_0-1678408255051.png

 

 

1 REPLY 1
FreemanZ
Super User
Super User

hi @desbarden 

try like:

Trial =
VAR _kpi = CALCULATE(SUM('RAN AH'[Daily]),'Date'[Date] = SELECTEDVALUE('DAY'[Time]))
VAR _max = MAXX(ALL('Date'[Date]), 'Date'[Date])
VAR _allowed_dates = {_max_max - 1, _max -7, TODAY()}
RETURN
        IF(SELECTEDVALUE('DAY'[Time]) IN _allowed_dates, _kpi , BLANK())

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.