Power Query / DAX solution to Excel formulas (or if this is even appropriate)

IR15H

New Member
Joined
Jun 8, 2013
Messages
10
Hello,

I've been using Excel for years but have recently been seduced by the appeal of Power BI as a means of providing more 'visually friendly' reports for other users to view and analyse. Whilst I can generally get Excel to do what I want to do (possibly through horrendously inefficient formulas/code), Power BI is just boggling my mind at the moment.

The issues is such; I have a large data source, that I have no ability to change, that's updated weekly and I download. I've currently written a macro that I run on each download that basically adds a load of additional columns containing formulas - I then save the Excel file and refresh my data source in Power BI, which makes all the visuals look pretty. However, I feel this is essentially a cop out of using Power BI fully - and that the 'proper' solution (given that I can't change the original data source) would be import the unedited report into Power BI directly and then use Power Query / DAX to alter/add to the data as required.

My Excel data is as below (which I sort by Column F, then R and then S, before my applying formulas in columns V-AD);

FOPRSUVWXYZAAABACAD
1Employee No.On CalRoster DateShift StartShift FinishShift PaidOn Call?Rest<12hrs>12hrs7 days>60hrs>72hrsConsecutive13+ shifts
2Number/TextY/NDD-MM-YYDD-MM-YY HH:MM:SSDD-MM-YY HH:MM:SSH.MM=IF(O2="Y",IF(SUMPRODUCT(($F$2:$F2=F2)*($P$2:$P2=P2))>1,0,1),0)=IF(F2<>F1,23.99,IF(R2="",23.99,IF(S1="",23.99,(R2-S1)*24)))=IF(AND(W2<12,W2>0),1,0)=IF(W2=0,IF(U2+U1>12,1,0),IF(U2>12,1,0))=SUMIFS(U:U,F:F,F2,P:P,"<="&P2,P:P,">="&P2-6)=IF(Z2>60,IF(P2=P3,0,1),0)=IF(Z2>72,IF(P2=P3,0,1),0)=IF(F2=F1,IF(R2<>"",IF(P2=P1,AC1,IF(P2-P1=1,AC1+1,1)),0),0)=IF(AC2>13,IF(P2=P3,0,1),0)

<tbody>
</tbody>

The primary reason for needing all the additional formulas is there can be multiple entries for the same employee number (F), on the same date (P) and its important to distinguish if these entries and consecutive or not (based on start start/finish times (R/S)) but at the same time not double counting those entries for other measures. What I want to know/learn how to do is convert the above formulas to DAX and/or Power Query equivalents, if possible? I've attempted this a few times before by googling/reading stuff but usually just end up confusing myself even more.

The above is actually one of three sheet I do similar things to, but I figure if I can get the above cracked (or even just some of it) I'll be able to figure out the rest from there.

Any help appreciated and if you need any more info please let me know.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi,

Thanks for your response and link, I managed to get some of the more simpler formulas to work (and can probably figure out the rest when I get a bit more time).

I think the main thing that threw me was that some of my Excel formulas have a relative reference to a row above or below... and I was trying to do things like;

Code:
if [A] - 1 = [B] then "A - 1 = B" else "A-1 <> B"

Which just wasn't working and then going round in circles by trying to use 'Excel logic'.

I've since found this and this link, which seem to suggest the way to do it is via some form of index columns. Again, hopefully when I get a bit more time, I can follow through and achieve what I'm after.
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,952
Members
448,535
Latest member
alrossman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top