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
jeyare
Helper II
Helper II

I'm looking for a record with double growth

So, a speciall challenge is here.

 

Single table of data for the calculation (sample):

IDDateBranchValueX
11.1.2021A60
21.1.2021B40
31.1.2021C20
42.1.2021A30
52.1.2021B100
62.1.2021C50
73.1.2021A120
83.1.2021B30
93.1.2021C110
104.1.2021A30
114.1.2021B80
124.1.2021C10
135.1.2021A20
145.1.2021B210
155.1.2021C40

 

Target No. 1:

I need find for each record in column [ValueX], Filtered by column [Branch] and Date within column [Date] based on all of these conditions:

1. Double of the [ValueX], lets describe it as [DoubleValueXPOS] is each number what is >= than 2x of value in [ValueX]

2. I need take into account only nearest record what is NEWER than [Date] of the evaluated [ValueX]

3. for each the [Branch] independently

Finaly I need create a new Column [Doubling Days POS] where I will a Subtract of [Date] of my base number and discovered Double date by [DoubleValueX].

 

An example (described):

when ID = 1 contains Date = 1.1.2021; Branch = A; ValueX = 60

then

Nearest double for ID = 1 is ID =7 because:

it's same Branch

ValueX (ID7) >= than 2x of value in [ValueX] in (ID1)

Doubling Days = Date of ID7 - Date of ID1 = 2

 

An example (in table):

IDDateBranchValueXDoubling Days POS
11.1.2021A602
21.1.2021B401
31.1.2021C201
42.1.2021A301
52.1.2021B1003
62.1.2021C501
73.1.2021A120 
83.1.2021B301
93.1.2021C110 
104.1.2021A30 
114.1.2021B801
124.1.2021C101
135.1.2021A20 
145.1.2021B210 
155.1.2021C40 

 

---------------

Target No. 2 (similar but reverse order in Date and smalest than ...):

I need find for each record in column [ValueX], Filtered by column [Branch] and Date within column [Date] based on all of these conditions:

1. Double of the [ValueX], lets describe it as [DoubleValueXNEG] is each number what is <= than 2x of value in [ValueX]

2. I need take into account only nearest record what is OLDER than [Date] of the evaluated [ValueX]

3. for each the [Branch] independently

Finaly I need create a new Column [Doubling Days NEG] where I will a Subtract of [Date] of my base number and discovered Double date by [DoubleValueX].

 

An example (described):

Last possible Day is  Max ([Date]) = 5.1.2021; Branch = C ; ValueX = 40; ID =15

then

Nearest double for ID = 15 is ID =12 because:

it's same Branch

ValueX (ID12) <= than 2x of value in [ValueX] in (ID15)

Doubling Days = Date of ID15 - Date of ID7 = 1

 

An example (in table):

IDDateBranchValueXDoubling Days POSDoubling Days NEG
11.1.2021A602 
21.1.2021B401 
31.1.2021C201 
42.1.2021A3011
52.1.2021B10031
62.1.2021C5011
73.1.2021A120 2
83.1.2021B301 
93.1.2021C110 1
104.1.2021A30 1
114.1.2021B8011
124.1.2021C1011
135.1.2021A20  
145.1.2021B210  
155.1.2021C40 1

 

Thx for a help

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @jeyare ,

 

I understand the first target but however I'm confused about the negative.

 

I have created the following measures:

 

Doubling Days POS =
VAR temp_table =
    FILTER (
        SUMMARIZE (
            ALL ( 'Table'[Branch]; 'Table'[Date]; 'Table'[ID]; 'Table'[ValueX] );
            'Table'[Branch];
            'Table'[ID];
            'Table'[Date];
            'Table'[ValueX]
        );
        'Table'[ValueX]
            >= 2 * SELECTEDVALUE ( 'Table'[ValueX] )
            && 'Table'[Branch] = SELECTEDVALUE ( 'Table'[Branch] )
            && 'Table'[Date] > SELECTEDVALUE ( 'Table'[Date] )
    )
RETURN
    DATEDIFF (
        SELECTEDVALUE ( 'Table'[Date] );
        MINX ( temp_table; 'Table'[Date] );
        DAY
    )


Doubling Days NEG =
VAR temp_table =
    FILTER (
        SUMMARIZE (
            ALL ( 'Table'[Branch]; 'Table'[Date]; 'Table'[ID]; 'Table'[ValueX] );
            'Table'[Branch];
            'Table'[ID];
            'Table'[Date];
            'Table'[ValueX]
        );
        'Table'[ValueX]
            <= 2 * SELECTEDVALUE ( 'Table'[ValueX] )
            && 'Table'[Branch] = SELECTEDVALUE ( 'Table'[Branch] )
            && 'Table'[Date] < SELECTEDVALUE ( 'Table'[Date] )
    )
RETURN
    DATEDIFF (
        MAXX ( temp_table; 'Table'[Date] );
        SELECTEDVALUE ( 'Table'[Date] );
        DAY
    )

 

Check result below. My question is regarding the ID 8 , 13 and 14 since I'm not abble to return blank has you since you are comparing values with the double of the selected value everything single value. 

 

 

MFelix_0-1610455820197.png

 

PBIX file attach.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @jeyare,

Did MFelix 's solution help for your scenario? If this is a case, you can consider accepting this to help others who face similar scenarios to find it more quickly.
If not, you can feel free to post here with detailed information.
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
MFelix
Super User
Super User

Hi @jeyare ,

 

I understand the first target but however I'm confused about the negative.

 

I have created the following measures:

 

Doubling Days POS =
VAR temp_table =
    FILTER (
        SUMMARIZE (
            ALL ( 'Table'[Branch]; 'Table'[Date]; 'Table'[ID]; 'Table'[ValueX] );
            'Table'[Branch];
            'Table'[ID];
            'Table'[Date];
            'Table'[ValueX]
        );
        'Table'[ValueX]
            >= 2 * SELECTEDVALUE ( 'Table'[ValueX] )
            && 'Table'[Branch] = SELECTEDVALUE ( 'Table'[Branch] )
            && 'Table'[Date] > SELECTEDVALUE ( 'Table'[Date] )
    )
RETURN
    DATEDIFF (
        SELECTEDVALUE ( 'Table'[Date] );
        MINX ( temp_table; 'Table'[Date] );
        DAY
    )


Doubling Days NEG =
VAR temp_table =
    FILTER (
        SUMMARIZE (
            ALL ( 'Table'[Branch]; 'Table'[Date]; 'Table'[ID]; 'Table'[ValueX] );
            'Table'[Branch];
            'Table'[ID];
            'Table'[Date];
            'Table'[ValueX]
        );
        'Table'[ValueX]
            <= 2 * SELECTEDVALUE ( 'Table'[ValueX] )
            && 'Table'[Branch] = SELECTEDVALUE ( 'Table'[Branch] )
            && 'Table'[Date] < SELECTEDVALUE ( 'Table'[Date] )
    )
RETURN
    DATEDIFF (
        MAXX ( temp_table; 'Table'[Date] );
        SELECTEDVALUE ( 'Table'[Date] );
        DAY
    )

 

Check result below. My question is regarding the ID 8 , 13 and 14 since I'm not abble to return blank has you since you are comparing values with the double of the selected value everything single value. 

 

 

MFelix_0-1610455820197.png

 

PBIX file attach.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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.