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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
adnanarain
Helper V
Helper V

equivalent of tableau Function: Lookup and first

Dear all,

I am using the following tableau formula:

 

LOOKUP(count([Account_Number]),FIRST()) - LOOKUP(ZN(count([Account_Number])), 0)

 

I need to convert this formula in power bi.

Thanks in advance for help

1 ACCEPTED SOLUTION

hi @adnanarain 

Just create two measure as below:

Difference = 
var _lastrow=CALCULATE([Number of accounts],FILTER(ALL('Table'[Date Difference]),'Table'[Date Difference]=MAX('Table'[Date Difference])-1))
return

IF(ISBLANK(_lastrow),0,_lastrow-[Number of accounts])
% = var _lastrow=CALCULATE([Number of accounts],FILTER(ALL('Table'[Date Difference]),'Table'[Date Difference]=MAX('Table'[Date Difference])-1))
return

DIVIDE([Difference],_lastrow,0)

Result:

4.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
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

8 REPLIES 8
v-lili6-msft
Community Support
Community Support

hi  @adnanarain 

There are some workaround to get it, but it depends on your data structure.

Sample data and expected output would help tremendously.
Please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Lin

 

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

I am attaching sample data and the desired output. with this data, I am using matrix visual to find number of accounts, Difference, and %. Number of accounts is a simple  count([account Number]) and the difference for row 0 (i.e Date Difference Column) will always be 0 and Row 1 is Account numbers of Row 0 - account numbers of Row 1, in example Account numbers of Row 0 = 3 and Account numbers of Row 1 = 1 so the difference for Row 1 will be 3-1 = 2 and last I want to calculate % for Row 0 the % will be 0 and for Row 1 the formula for % is difference (i.e 2 for Row 1) divided by count of account number for Row 0 (i.e 3) so 2/3 = 67%.

Below is the sample data:

Date Difference        Account Number              Account Open date
012013
022013
032014
022013
032014
032014
142014
152013
162014
272013
282014
292013
3102013
3112014
4122013
4132013
4142014
4152014

 

and below is the desired output, I tried to show for Year 2013 only:

 

 2013                             
Date Difference      Count of account        Difference         %
0300%
11267%
22-1-100%
31150%
42-1-100%

I tried to explain, apologies in advance if anything is not clear.

amitchandak
Super User
Super User

@adnanarain , What I got from it is that it is a row operation function, to move up and down in row by giving a number of first and last.

There is no equivalent to that.

Based on what you need you can a function like you can use time intelligence to get prior months/qtr or year. Or Rank to move up and down in incremental values. 

Time intelligence example

https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-1-Time-Intell...

 

Rank example

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

parry2k
Super User
Super User

@adnanarain you need to explain what this function does, maybe a lot of us don't know what this function returns, better to put some sample data and expected output.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k  i tried to explain in above message please have a look.

@parry2k  @v-lili6-msft  @amitchandak I am attaching sample data and the desired output. with this data, I am using matrix visual to find number of accounts, Difference, and %. Number of accounts is a simple  count([account Number]) and the difference for row 0 (i.e Date Difference Column) will always be 0 and Row 1 is Account numbers of Row 0 - account numbers of Row 1, in example Account numbers of Row 0 = 3 and Account numbers of Row 1 = 1 so the difference for Row 1 will be 3-1 = 2 and last I want to calculate % for Row 0 the % will be 0 and for Row 1 the formula for % is difference (i.e 2 for Row 1) divided by count of account number for Row 0 (i.e 3) so 2/3 = 67%.

Below is the sample data:

Date DifferenceAccount NumberAccount Open date
012013
022013
032014
022013
032014
032014
142014
152013
162014
272013
282014
292013
3102013
3112014
4122013
4132013
4142014
4152014

 

and below is the desired output:

 

 20132014
Date DifferenceCount of accountDifference%Count of accountDifference%
0300%300%
11267%2133%
22-1-100%1150%
31150%100%
42-1-100%2-1-100%

I tried to explain, apologies in advance if anything is not clear.

hi @adnanarain 

Just create two measure as below:

Difference = 
var _lastrow=CALCULATE([Number of accounts],FILTER(ALL('Table'[Date Difference]),'Table'[Date Difference]=MAX('Table'[Date Difference])-1))
return

IF(ISBLANK(_lastrow),0,_lastrow-[Number of accounts])
% = var _lastrow=CALCULATE([Number of accounts],FILTER(ALL('Table'[Date Difference]),'Table'[Date Difference]=MAX('Table'[Date Difference])-1))
return

DIVIDE([Difference],_lastrow,0)

Result:

4.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

Thank you so much for the help

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.