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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Loop-like feature in Power BI?

Dear all

 

I am trying to return different value in a new column if I find a specific value in several rows.

 

For example, I am trying to return the earliest view date when I found "Contact Customer Service" for each case and return, and if there is no any "Contact Customer Service" for a case, return the last view date.

 

Is it possible to have this loop funtion in Power BI? 

 

CaseTime_StampActionFirst or Last View
X0012/1/2021View2/1/2021
X0012/3/2021View2/1/2021
X0012/18/2021Place into Cart2/1/2021
X0012/19/2021Contact Customer Service2/1/2021
X0012/22/2021Cancel2/1/2021
X0021/3/2021View1/3/2021
X0021/19/2021Place into Cart1/3/2021
X0022/3/2021Purchase1/3/2021
X0022/7/2021Paid1/3/2021
X0033/2/2021View3/6/2021
X0033/4/2021View3/6/2021
X0033/5/2021Place into Cart3/6/2021
X0033/6/2021View3/6/2021
X0033/11/2021Paid3/6/2021

 

Thank you in advance!

1 ACCEPTED SOLUTION

View Date CC = 
VAR __v =
    FILTER(
        'CASE',
        'CASE'[Case] = EARLIER( 'CASE'[Case] ) && 'CASE'[Action] = "View"
    )
RETURN
    IF(
        ISEMPTY(
            FILTER(
                'CASE',
                'CASE'[Case] = EARLIER( 'CASE'[Case] ) && 'CASE'[Action] = "Contact Customer Service"
            )
        ),
        MAXX( __v, 'CASE'[Time_Stamp] ),
        MINX( __v, 'CASE'[Time_Stamp] )
    )

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1655871958709.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Thanks for your answer! Yet, there is an error "A circulated dependency was detected..." now.  

 

In your file, this error is not found, but the result seems different. 😞

 

column.JPG

 

Could you kindly take another look? Much appreciated!

View Date CC = 
VAR __v =
    FILTER(
        'CASE',
        'CASE'[Case] = EARLIER( 'CASE'[Case] ) && 'CASE'[Action] = "View"
    )
RETURN
    IF(
        ISEMPTY(
            FILTER(
                'CASE',
                'CASE'[Case] = EARLIER( 'CASE'[Case] ) && 'CASE'[Action] = "Contact Customer Service"
            )
        ),
        MAXX( __v, 'CASE'[Time_Stamp] ),
        MINX( __v, 'CASE'[Time_Stamp] )
    )

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

The 

MAXX( __v, 'CASE'[Time_Stamp] ),
        MINX( __v, 'CASE'[Time_Stamp] )

The MINX should come first and MAXX come second, but this DAX and logic work for me. Thanks again! 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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