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
Anonymous
Not applicable

Want to develop a logic inside Power BI Desktop

Hi All,

Trying to achieve same condition in Power BI,Please Help me:

if(Calendar_Week_Relative = 0,
sum({$<$(vSetChart), Stocking_Order_Type={'Outbound'}, Calendar_Week_Relative = {'<=0'}>} Total Total_$(vMeasure)),
sum({$<$(vSetChart), Stocking_Order_Type={'Outbound'}, Calendar_Week_Relative = {'>0<=12'}>} Total_$(vMeasure)))

1 ACCEPTED SOLUTION

@Anonymous,

 

Check measure below and take a look at this article.

 

Measure 2 =
VAR w =
    SELECTEDVALUE ( Table1[week_relative] )
RETURN
    IF (
        NOT ( ISBLANK ( w ) )
            && w = 0,
        CALCULATE ( [Measure], Table1[week_relative] <= 0 ),
        [Measure]
    )

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may use SUMX in DAX.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ryan_mayu
Super User
Super User

@Anonymous

 

Could you please provide the screenshots of your sample data and the result you expected?

 

Thanks & BR

Ryan





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

I don't have any sample data, Here i'm trying to achieve the solution like:
Sample Data:
week_relative:            Measure:
-1                               10
-2                               20
(Blank)                       30
0                                40
1                                 50
2                                 60
Trying to achieve,
if ([Week_relative]=0,
calculate(sum(measure),[week_relative]<=0    I.e. (10+20+30+40),
else show the result as it is
week_relative     Measure
1                          50

2                          60

@Anonymous,

 

Check measure below and take a look at this article.

 

Measure 2 =
VAR w =
    SELECTEDVALUE ( Table1[week_relative] )
RETURN
    IF (
        NOT ( ISBLANK ( w ) )
            && w = 0,
        CALCULATE ( [Measure], Table1[week_relative] <= 0 ),
        [Measure]
    )

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Sam,

It works fine, thnaks muuch for the help!!

Anonymous
Not applicable

Please ignore $(vSetChart) and Total_$(vMeasure), just want to impement If logic to Date dimenssion.

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.