Expressions that yield variant data-type cannot be used to define calculated columns.

Error:

Expressions that yield variant data-type cannot be used to define calculated columns.

Cause:

IF based Calculated Columns in Power BI or Power Pivot with 2 different data types is not allowed.

Solution:

Format one data type as needed using FORMAT() function.

[code language=”sql”]

Age = IF (
TableName[Birthday] < TODAY(),
FORMAT (
Year ( TODAY() )- Year ( TableName[Birthday] ),"General Number" ),
"Invalid birth date"
)

[/code]

FORMAT Function (DAX): https://msdn.microsoft.com/en-us/query-bi/dax/format-function-dax

Pre-Defined Numeric Formats for the FORMAT function: https://msdn.microsoft.com/query-bi/dax/pre-defined-numeric-formats-for-the-format-function

Creating an e-book. Part 3.

Continuing the series about how to create an e-book. Today we’ll have a much shorter post. Specifically, we’ll look at how to create the Title page.

So, what is a Title Page? According to dictionary.com, Title Page is: “the page at the beginning of a volume that indicates the title, author’s or editor’s name, and the publication information, usually the publisher and the place and date of publication.”

If you’ll search Google Images for “title page”, you see lots of examples of how a Title Page looks like. And, it seems to be the easiest to create. Technically speaking, a bunch of paragraphs and that’s it.

Ok, following dictionary.com’s description, let’s create our Title Page. We will need the following:

  • Book title: I will use “My Book’s Title”
  • Author name: this is simple, “Vitalie Ciobanu”
  • Publisher info: I do not have one so I will use “Lorem Ipsum Publishing Inc.”
  • Place and date of publication: “Madagascar 2018”. I still want to visit this island…

Open mybook.html page in Notepad and add above details right before your first chapter (which should be <h2> tag); each detail on different row and inside a paragraph element (<p></p>). Here is my <body> element now (trimmed):

[code language=”html”]
<body>My Book’s Title

Vitalie Ciobanu

Lorem Ipsum Publishing. All rights reserved.

Madagascar 2018
<h2>Lorem Ipsum</h2>
<h3>What is Lorem Ipsum?</h3>
<p class="first">Lorem ipsum dolor sit….</p>
<p class="quote">Nullam tortor orci…..</p>

Curabitur ligula tortor, ullamcorper….

</body>
[/code]

And here’s my page viewed in a browser:

Because we have p selector defined in our stylesheet file, you see above we have some formatting applied already. Let’s add additional selectors to the stylesheet to make Title page information differently looking. So, let’s add some different formatting for book title, author, publisher and date of publication. Here’s just some basic CSS added to my epub.css file:

[code language=”css”]
p.booktitle {
    text-indent:0em;
    text-align:center;
    margin-top:5em;
    font-weight:bold;
    font-size:150%;
}

p.bookauthor {
    text-indent:0em;
    text-align:center;
    margin-top:1em;
    font-weight:bold;
    font-size:130%;
}

p.bookpublisher {
    text-indent:0em;
    text-align:center;
    margin-top:3em;
    font-weight:bold;
    font-size:100%;
}

p.bookpublished {
    text-indent:0em;
    text-align:center;
    margin-top:1em;
    font-weight:bold;
    font-size:100%;
}
[/code]

For each selector I wanted no indentation so I added “text-indent:0em”. Also, everything is centered and bold. Font size is different, with Book Title being the biggest one, 150%em. Lastly, I added different top margins to visibly separate each line. Afterwards, I updated the class details on my newly added paragraphs in html file.

[code language=”html”]
<body>
<p class="booktitle">My Book’s Title</p>
<p class="bookauthor">Vitalie Ciobanu</p>
<p class="bookpublisher">Lorem Ipsum Publishing. All rights reserved.</p>
<p class="bookpublished">Madagascar 2018</p>

<h2>Lorem Ipsum</h2>
<h3>What is Lorem Ipsum?</h3>
<p class="first">Lorem ipsum dolor sit….</p>
<p class="quote">Nullam tortor orci…..</p>

Curabitur ligula tortor, ullamcorper….

</body>
[/code]

Here’s the updated view in browser.

How to automatically create and update Visio diagrams from Excel

To successfully create Visio diagrams from Excel, Visio Pro for Office 365 is required. Here you can see the prices or download trial.

  1. Open Excel (I have latest release of Excel from Office 365 suite)
  2. In the search box, type “process” and hit Enter. Among other search results, 2 Excel templates should appear with Excel icons in upper left corner and Visio diagrams in lower right corner. Select the one you want/need. I will continue with Process Map for Cross-Functional Flowchart.

  3. A nicely formatted Excel file will open with pretty much all info you need to know about Data Visualizer; the solution that allows us to create diagrams from Excel.

  4. Head over to Process Map worksheet.
  5. You’ll notice here we have “ProcessMapDataTable populated with 2 rows. This is the Excel Table that we need to work with. Everything else can be deleted/ignored.

  6. Remove the 2 rows added as examples and add your process’ field mappings. For this example, I will use Software Development process found on www.smartdraw.com
  7. I will modify my Excel Table based on this process. Here is my final Table:
Process Step ID Process Step Description Next Step ID Connector Label Shape Type Function Phase
P01 Start P02 Start Project Management Planning
P02 Gather requirements P03 Document Project Management Planning
P03 Develop specifications P04 Process Software Design Design
P04 Develop internal design P05 Process Software Design Design
P05 Develop external design P06 Process Software Design Design
P06 Change required? P05,P07 Yes,No Decision Software Design Design
P07 Define Development team P08 Subprocess Software Development Coding
P08 Application development P09 Process Software Development Coding
P09 User Acceptance Testing P10 Process Software Development Coding
P10 Quality Assurance P11 Process Software Development Coding
P11 Defects P08,P12 Yes,No Decision Software Development Coding
P12 Release to production P13 Subprocess Release Management Release
P13 Stop End Project Management Release

Make sure that you have more than one value in Next Step ID, you should have similar number of values/labels in Connector Label column and that those values match its corresponding step.

For example, P06 Step ID is a decision point. If changes are required (Yes), process goes back to P05 Step ID. If no changes are required (No), process proceeds to P07 Step ID.

Lastly, ensure your last process step has nothing in Next Step ID field, because it’s the last one, there is nothing else afterwards… process ends here. Save your Excel file.

  1. Open Visio.
  2. In the search box, type “data visualizer” and hit Enter. You should get the Basic and Cross-Functional templates. Select the same one you used for creating the Excel file. Cross-Functional Flowchart in my example.

    Just in case you started it wrongly or you want to get Excel template again, click Excel data template. Select your local Unit and click Create.

  3. Visio will open Create Diagram from Data wizard.
  4. Using first drop-down box, select the correct diagram type to use.
  5. In the second field, browse to the Excel file you created and saved in Step 7.
  6. In the last field, Visio should automatically recognize your Excel Table name, ProcessMapData in my example. Click Next.

  7. If you did not modified headers in the Excel Table, next page should automatically recognize and map Function and Phase columns. Expand More Options if you want to modify the order of column values. Assuming you created your process in a chronological order, you’d probably want to retain the same order in Visio.

  8. On the next wizard page the same, if you left all default column headers, Visio will automatically recognize and map needed columns. Otherwise, drag and drop the columns from the left.

    Short note here: you probably noticed your Excel Table has blue and green headers. Blue headers are required for these mappings and building your final diagram. Whether green columns are nice to have. All those columns may have valuable info for the diagram, but I think Microsoft still has ways for improvement this specific side, especially Alt Description, because it may contain too much text. Add something to this column and you will see what I’m referring to.

  9. Next page is about choosing your required Visio shapes. I did not have anything to modify or comment here. It seems like Microsoft is limiting the user to use predefined shapes but, anyway, default shapes are kind of standard so should be sufficient.

  10. The last wizard step is the one we need to modify to suit our needs. Make sure Next Step ID is selected for Specify Column Name, Relationship is set to Next Step, Delimiter is set to comma and Connector Label is mapped to its column with same name. Click Finish.

  11. You should now have a fully functional Visio diagram. Note that Visio will zoom it in such a way that it fits your page; if needed, zoom it in or out to see the details. Also, for some reason, Visio creates a lot of unused space between each shape. Feel free to rearrange everything to save space.

One nice thing about having this Excel file linked to Visio is that any updates you make to the process in Excel, you can refresh Visio diagram to update it with those changes. Just select your Visio diagram and from Data tab, in Create from Data group select Refresh.

For reading official Microsoft article about this, please take a look at “Create a Data Visualizer diagram” post. It contains more valuable info, including a description about each Excel columns that interact with Visio flowchart components.

Similarly, here’s a video made by Microsoft.

July 20, 2018: Microsoft just posted another, shorter, video on YouTube marketing same thing.

How to start Word with a specific template

  1. Open Word the usual way.
  2. In the template selection view, select the template you want and click Create. For example, Blog Post.
  3. When Word opened your document, click Save As and select Word Template in the Save as type drop-down box.

    Path should change automatically to your Custom Office Templates directory.
    Give your template a name. For example Blog, to keep it simple. At this point, you can close this document.

  4. On your Desktop or wherever you want, right click and select NewShortcut.

  5. In the location field, add full path to winword.exe file; default location for 2016 version is “C:\Program Files\Microsoft Office\root\Office16”. Also, you need to specify the location and name of your template file. Mine is in “D:\_Main Documents\Documents\Custom Office Templates” so my full path will be (including quotes and template name): “C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE” /t”D:\_Main Documents\Documents\Custom Office Templates\Blog.dotx”

    Make sure there is a space before /t switch and there is no space between the /t switch and template path. Click Next.

  6. Give your new shortcut a name; Blog from Word for example. Click Finish.

  7. Your new shortcut is now ready for use. Double click it and Word will open using your new template without asking anything else.

Optionally, it’s more a nice to have actually, you can personalize your shortcut with a custom icon so that you can quickly differentiate it from other Word files and shortcuts.

  1. Right click your new shortcut and select Properties.
  2. Click Change Icon… and browse to the location where you have an .ico (ICO file format is an image file format for Windows icons) file you want to use.

    If you do not have an icon to use, click Browse and in File name box type: %SystemRoot%\System32\SHELL32.dll
    Here you have quite a few old but good icons that you can choose from. Select one icon and click OK twice.

  3. Your shortcut is now fully customized and ready for use.

How to use Word for Blog publishing

  1. Start your Office Word application. It works with any version starting with Word 2007.
  2. While you’re in the new template selection view, search for “blog” in the “Search for online templates” field.

  1. Blog post” template should be listed. Click it and then select Create button.

  2. On first run only, you’ll be asked to register your blog in Word. You can click Register Now and walk through this process or you can click Register Later and do it later by using Manage Accounts from Blog command group.

  3. If you clicked Register Now, you’ll be asked to select your blog provider. You see that this list does not include all possible blogging platforms, that’s kind of normal I’d say…, but you have the Other option and you then can add any blog details as long as you know the link to provider’s API.

    I selected WordPress because this is what I have.

  4. Next screen will ask for your blog’s URL. And, this is different from platform to platform but, for WordPress you need to provide the link to your xmlrpc.php file. It is usually in your root folder of your site but if it is in another folder, make sure to add the correct path.

    For default location, just paste your site’s address between the backslashes, thus replacing <Enter your blog URL here> with your blog’s URL.

    Add your username and password. Optionally, select Remember Password if you’re the only one who’s using your Windows account. If there are more people using same Windows account, to prevent others posting funny things to your blog, leave this option unchecked.

    Under Picture Options, you can select where your post’s pictures will be uploaded to. For simplicity, keep it as My blog provider.

  5. Once you have all fields completed, hit OK.

  6. If everything was done correctly and Word could connect to your blog, you’ll be presented with a nice confirmation message.
  7. Next, you’ll have your Word template changed to Blog. Notice Blog command group. It contains all your basic needs for creating and publishing blog posts. One thing is missing though, ability to add Tags.

    If you have a more complex blog, photography maybe or e-commerce, or if you use Featured Images or you need to add Location to your posts, probably Word is not that much suitable to you.

  8. From Insert tab, you have access to add a lot of items to your post, like images, shapes, tables etc.. As an example, below picture has Rounded Corners style added.

Below is a shape added from Word, it will be posted as a picture:

 

Just in case something went wrong and you have issues connecting to your blog or uploading images, please take a look at Microsoft’s article about this, scroll down to the bottom for troubleshoot problems.

Creating an e-book. Part 2.

Following on from previous post about creating an e-book, today we will make that “black on white” text look nicer and we will do it using CSS (Cascading Style Sheets).

I will not detail on what CSS is because this is not the purpose of this post. If you need to refresh your knowledge, please head over to W3School’s page.

Very shortly though, CSS helps HTML look nicer and it does so by defining how each HTML element should be displayed in a browser.

By now, we know that an e-book is basically HTML. Plain HTML documents can be read by most browsers in the same way, which is not the case about e-books. Because e-books can be read on e-readers, computers, tablets, phones etc., screen sizes will differ, same will font size, page width etc. With this in mind, we need to ensure that we use relative sizes and not sizes in pixel (PX); so we’ll use either percentage (%) or em (EM).

    Quoting W3Schools: What is the difference between PX, EM and Percent?

Pixel is a static measurement, while percent and EM are relative measurements. The size of an EM or percent depends on its parent. If the text size of body is 16 pixels, then 150% or 1.5 EM will be 24 pixels (1.5 * 16). Look at CSS Units for more measurement units.

Again, very shortly, 1em equals to current device’s font size, 100%. 1.5em will be 150% of current font size. 2em will be 200%…, you got the idea.

Although we can add CSS properties and selectors inside .html file, we will create a separate .css file and will link it from .html file. This way, you can very easily use same CSS file as template for other books, instead of copy/pasting specific text from inside .html file.

OK, let’s open a blank notepad file and save it as epub.css in the same folder where mybook.html. Let’s add one additional line to our .html file so that it knows where to look for this .css file.

Right click mybook.html file and open it with notepad. Add one new line after <meta> and before <title> tags and add: <link rel=”stylesheet” href=”epub.css” />

[code language=”html”]
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="epub.css" />
<title>My Book’s Title</title>
[/code]

As mentioned previously, out of all HTML tags, we will use Headings and Paragraphs the most in any e-book, throughout the entire book. Let’s then start with defining Headings because we need them for Chapter titles and subtitles. Again, using CSS we can design our HTML to look awesome and each of you will have your own definition of awesome and, why not, design skills, which I surely lack.

Let’s say in our e-book we want Chapter Title to be 1) aligned to the right and 2) have an additional 2 free lines from the previous block of text. To accomplish all this, in our epub.css file we will write below code for h2:

[code language=”css”]
h2 {
text-align:right;
margin-top:2em;
}
[/code]

Save .css file and leave it open. Now open mybook.html in a browser. See how our Chapter Title changed from left to right and the space before and after it? Just to show you how easy it is to change something using CSS, let’s say we want Chapter Title to be in red… in epub.css add color:red; text on the next line after margin-top:2em;. Save the file and then refresh html file in your browser. Your title should now be in red.

Now think about it a little. What if you would have a book with hundreds of pages, with hundreds of Chapter Titles? With one line added the CSS file, you changed the look of all Chapter Titles. How cool is that?! Let your imagination flow and modify your CSS file as you wish to make your e-book look great!

Ok, before going on, let’s remove the line with red color, unless you want to leave it of course.

Regarding Chapter Subtitles, let’s say we want them also 1) right-aligned but 2) style should be italic. Below is the code to make this happen:

[code language=”css”]
h3 {
text-align:right;
font-style:italic;
}
[/code]

Regarding paragraphs, as you recall, I added 3 paragraphs in my .html file; I did this because I wanted to show you 3 different examples of paragraphs modified through CSS styles. So, let’s make all default paragraphs justified, first line indented by 2em, without any margins on left or right (because we want to use as much space as possible) but we do want to have a little bit of size before next paragraph starts. Here’s how we can accomplish this:

[code language=”css”]
p {
text-indent:2em;
text-align:justify;
margin:0em;
margin-bottom:0.25em;
}
[/code]

Next, we will also use a paragraph but with a purpose. For example, when we will want to quote something or add few lines of text that is totally different from other paragraphs etc. We’ll make it center aligned, italic and will add some space before and after so that it is visible and distinguished.

[code language=”css”]
p.quote {
text-align:center;
margin-top:0.5em;
margin-bottom:0.5em;
font-style:italic;
}
[/code]

In the above code you will notice a small addition to our CSS style. By adding p.quote, we’re just specifying that any paragraph with quote
class, should have these additional changes applied (for example, if we will not add text-align:center;, this paragraph will remain justified because this is what text-align for all paragraphs says).

If you’re more curious… similarly, if you will add only .quote for example, that means any HTML tag where you will add quote class will have those changes applied.

Seems easy and straightforward to me. Again, think about how easy you can modify an entire book?! You can take same .html file and only make changes in the CSS file to get a completely different book. Think about how easy you can create books for readers with low vision, blindness or visual impairments! Try and play with the menu from W3Schools and you’ll be amazed of what you can do with CSS.

For last paragraph mainly I want to make you interested in “what else can I do easily?”. Let’s modify only first paragraph in any chapter so that it has a visual delimiter from Chapter Subtitle.

[code language=”css”]
p.first {
margin-top:1em;
}
[/code]

At this point, I have defined my 3 paragraphs like this: First is first obviously; Second is a quotation-like and Third is just a normal paragraph. Here is my html code inside <body> tags (I’ve cut the text in code to make it shorter but it is visible in the screenshot in its full width):

[code language=”html”]
<body>
<h2>Lorem Ipsum</h2>
<h3>What is Lorem Ipsum?</h3>
<p class="first">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p class="quote">Nullam tortor orci, dictum id vulputate ut, sagittis vel arcu.</p>
<p>Curabitur ligula tortor, ullamcorper placerat commodo eu, efficitur ut dui.</p>
</body>
[/code]

Here’s my webpage in IE: