Showing posts with label data. Show all posts
Showing posts with label data. Show all posts

Reading Notes #311

DateTimeImg2Suggestion of the week



Cloud


Programming

  • Styling Social Media Icon Lists in CSS (Mark Heath) - Yeah right, we can read CSS and probably hack some stuff... But it's excellent to learn how to do simple things the good way. And this post shows exactly that.


Data


Miscellaneous


Reading Notes #307

MVIMG_20171201_131034Cloud



Programming



Miscellaneous




Reading Notes #305

AzureDatabricks

Cloud


Programming


Miscellaneous


Reading Notes #302

Autumn

Cloud


Programming


Data


Miscellaneous




Reading Notes #301

300love

Programming


Data

Miscellaneous


  • My First Year as an MVP, part 1 (Jen Kuntz) - Interesting post. It feels soooooo familiar, and yet so far now. I look forward to meeting you in March fellow Canadian MVP.


Lessons Learned with Power Bi and Dynamic DAX Expressions

Since its availability, I try to use Power Bi as often as I can. It is so convenient, to build visual to explain data coming from a ton of possible data source. And it's a breeze to share it with clients, or colleagues. However, this post is not an info-commercial about Power Bi, it's about sharing some challenges I got trying to prepare a report and how I fix it.

The Data Source


The context is simple, all transactions are in one table, and I have a second table with a little information related to clients. To that, I personally like to add a calendar table, because it simplifies my life.

Datamodel

For this report, it is very important to but a slicer by Client.

The Goal


I needed to have one report that shows for every customer three different Year To Date (YTD) total. The classic YTO, a YTD but when the beginning of the years is, in fact, when the client started is enrolment, and the last one was a rolling twelve.
It looks pretty simple, and in fact, it's not that complicated. Let's examine each total formula one by one.

Classic Year To Date Total


Before we get started, it's a good practice to reuse Mesure to simplify our formula, and to explicit expression. Let's create a Measure for the Total Sales, that will be used inside our other formulas.

TotalSales = SUM('Sales'[Total])

Now the Year To Date, is simple to add by adding a New Measure and entering the formula:

YDTClassic = TOTALYDT([TotalSales], 'Calendar'[Date])

If you activate the Preview feature of Power Bi, it could be even easier. Look for the button New Quick Measure and select the Total Year To Date, fill up the form and voila!

QuickMeasure

The generated formula looks a bit different because Power Bi managed the error in h expression.

TotalYTD = 
IF(
    ISFILTERED('Calendar'[Date]),
    ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy."),
    TOTALYDT([TotalSales], 'Calendar'[Date].[Date])
)

Anniversary Year To Date Total


I spent more time then I was expecting on that one. Because in the Online DAX documentation it is said that the formula TOTALYDT accept a third parameter to specify the end of the year. So if I had only one client, with a fix anniversary date (or a fiscal year) this formula will work assuming, the special date is April 30th.
TOTALYDT([TotalSales], 'Calendar'[Date], "04-30")
However, in my case, the ending date changes at with every client. I'm sure right now you are thinking that's easy Frank just set a variable and that it! Well, it won't work. The thing is the formula is expecting a static literal, no variable aloud even if it returns a string.
The workaround looks at first a bit hard, but it's not that complex. We need to write our own YTD formula. Let's look at the code, and I will explain it after.

Anniversary YTD = 
VAR enddingDate =   LASTDATE(Company[EnrolmentDate])
VAR enddingMonth =  MONTH ( enddingDate )
VAR enddingDay =    DAY ( enddingDate )
VAR currentDate =   MAX ( Calendar[Date] )
VAR currentYear =   YEAR ( currentDate )
VAR enddingThisYear =   DATE ( currentYear, enddingMonth, enddingDay )
VAR enddingLastYear =   DATE ( currentYear - 1, enddingMonth, enddingDay )
VAR enddingSelected =   IF ( enddingThisYear < currentDate, enddingThisYear, enddingLastYear )
RETURN
    CALCULATE (
        [TotalSales] ,    
        DATESBETWEEN(Calendar[Date],enddingSelected,currentDate)    
    )
First lines are all variable's declaration. They are not required, but I found it easier to understand when things are very explicit. Since I'm slicing my report by companies putting the LASTDATE is just a way not avoid errors. It should have only one record. Then we extract year, month, and day.
The last variable enddingSelected identify if the anniversary (the end date) is pasted or not in the curent calendar year.
The calculate function is returning the TotalSales between the last anniversary date and today.

Rolling twelve Total


For the last formula, the rolling twelve we will re-use the previous code, but in a simpler way since the end date is always yesterday.

Rolling 12 Total = 
VAR todayDate = TODAY()
VAR todayMonth =    MONTH ( todayDate )
VAR todayDay =  DAY ( todayDate ) 
VAR todayYear = YEAR ( todayDate ) 
VAR enddingLastYear =   DATE ( todayYear - 1, todayMonth, TodayDayVar +1) 
RETURN
    CALCULATE (
        [TotalSales] ,
        DATESBETWEEN( Calendar[Date], enddingLastYear, todayDate)   
    )

Wrap it up


I definitely learned a few things with that Power Bi session, but it turns out to be pretty easy. Again, leave a comment or send me an email if you have any comments or questions I will be very happy to ear from you.


References


Reading Notes #273

Frank_AzureFunction-2Cloud


Programming


Miscellaneous



Reading Notes #272

Show_me_the_wayCloud


Programming


Databases



Where can I put my Data In Azure


This month, I’m the guest of Mario Cardinal (@mario_cardinal) and Guy Barrette (@GuyBarrette) on their Podcast The Visual Studio Talk Show.  A French Podcast that talk software architecture with Microsoft's technology. 
Alexandre Brisebois (@Brisebois) was also present on this episode, and the four of us spent about an hour talking about Data in Azure, and try to clarify the Microsoft offer.

You can listen to the episode here:  http://visualstudiotalkshow.libsyn.com/205-alexandre-brisebois-et-franois-boucher-les-donnes-et-azure

I did a little “Mindmap” before the show to help me keeping it as structured as possible. I’m sharing it with you here:
Azure Data_thumb

Version (3231x1130) here: http://cloudenfrancais.com/content/images/2017/03/Azure-Data.png

~Frank

Reading Notes #234

tree in a blue skySuggestion of the week


Cloud


Programming


Miscellaneous



Reading Notes #231

tulipSuggestion of the week

  • Introducing docs.microsoft.com - Great post that explains all the nice features of the first glimpse of the new Microsoft documentation. They did a fantastic work, a post to read; a site to remember.

Cloud


Programming


Data


Miscellaneous




Reading Notes #230

15288837503_ba2b786d93_zSuggestion of the week

  • Data Locality - Great troubleshooting session explained, definitely a post to read.

Cloud


Programming


Photo credit: Claus Tom via Foter.com / CC BY-NC-ND


Reading Notes #229

NewLogicAppDesignerCloud


Data


Programming

  • Become a Visual Studio 2015 Power User (Allison Buchholtz-Au, Andrew Hall) - All Visual Studio developers must watch this video, big chance you had a d in your hand and didn't know about it.

Miscellaneous

  • It's a new blog! (Troy Hunt) - A delicious post, thanks Troy to share that with us.


Reading Notes #228

IMG_20160416_085010Cloud

  • But Why Do You Trust Your Data? (Buck Woody) - I consider this post as a really great teaser. After ready his post most chances are you will check the video it recommended... and next give a shot to Azure data Catalog.

Programming


Data

  • Analyzing your Azure Search traffic (Berni Torres Garayar) - Great post that explains how to improve our services by listening to our client's search requests, leveraging the new Azure Search Analytics and PowerBi.

Miscellaneous


~Frank


Reading Notes #221

logo_JavaScriptSuggestion of the week

  • Why You Should Learn JavaScript in 2016 (Ken Powers) - I eared a lot of people complaining about Javascript, this excellent post explains why you undeniably, we should all know it, an if it's not the case why 2016 is a great time to learn it.

Cloud


Programming


Data

  • Power BI Service February Update (Amanda Cofsky) - Fantastic! This update will give us the possibility to share outside ou organization... And many other things.

Miscellaneous


~Frank


Reading Notes #220

Logic-AppSuggestion of the week


Cloud


Programming


Data

Book

  • Software Development Book Giveaway! - Cool! A great opportunity, 3 free books are given: Building Microservices, Working Effectively with Legacy Code, and Javascript: The Good Parts.

Miscellaneous



Reading Notes #219

AzureSDK2-8-2Suggestion of the week


Cloud


Programming


Books



Reading Notes #218

GuyAndErikSuggestion of the week


Cloud


Programming


Data



Reading Notes #215

Reading on the roadCloud


Programming


Data


Miscellaneous



Reading Notes #160

multipleCloudStorageSuggestion of the week


Cloud


Programming

  • Don't Frown on CSVs - Nice post that explains why we shouldn't over look the good old CSV format.

Miscellaneous


~Frank Boucher