Skip to content

DATA MODELING BEST PRACTICES

  • Power BI

To get the best results in your Power BI model, use the following below as a checklist

  • Data Model changes do not impact the source. If you need source data always changed, you will need to modify that directly or through Power Query
  • For the Data Model, only pull the data you need
  • If you need the database to do some work, push it back down to the database to do it. Save your local workstation the hassle.
  • Data warehouse…build one
  • Set your data types (date, decimel, etc)
  • Disable the default summarization
  • Categorize your Fields
  • Hide items you don’t need
  • If you don’t need certain data, remove it…. For instance, if you have Date and Time together in one column, split Time out from the Date, and remove it.
  • Reduce the number of distinct values in a field as much as possible. For example if you have Date and Time together in one column, and you need both, split them out, and keep both. It will reduce the number of distinct values altogether and improve the efficiency of your model.
  • Fact Table – Large Tables that has relationships out to Dimensions
  • Dimension Table – These are Small tables (filter on these and it will improve the efficiency of your model)
  • Star Schema – Set your Fact Table in the middle, and your Dimension Tables around the Fact Table
  • Snowflake Schema – Multiple Fact Tables and Multiple Dimension Tables
  • Your Tables must flow to the Fact Table in a single direction. If the flow is away from your fact table, your data will not be accurate
  • Oversampling and/or Ambiguity occurs when you have a table relationship set to both, or bidirectional, instead of in a single direction. Do not set the relationship to both as it increases performance overhead and can cause confusion in the engine
  • Within Power BI take the time to Categorize the fields that can be categorized (Select Field > Column Tools > Data Category > Select what category it is)
  • Within Power BI, in the fields section, you may see summarized data that shouldnt be summarized. You will need to change Summarized Data in the Summarization dropdown, to Don’t Summarize, where it makes sense…such as in the Key field.

POWER QUERY – SETTING PARAMETERS

  • Power BI

To use parameters, which expecially helps when moving files from your local computer to the web service, perform the following

Open Power Query Editor
Click Home
Select Manage Parameters
Click New
Give it a Name (tacticalware)
Specify a Type from the drop down. For me I selected Text
In the Current Value field, specify the location of the csv file (C:\tacticalware\x.csv)
NOTE – it is case sensitive
Click Ok

Now go into your Advanced Editor
Find the location of the csv file (C:\tacticalware\x.csv)
Replace the path with the Name of the parameter (tacticalware)
So it will look like this:
Source = Csv.Document(File.Contents(tacticalware),……and so on
Click Done


POWER BI – QUERY FOLDING

  • Power BI

What is Power Bi Query Folding…..
– It reduces trips to the data source
– Pushes transformations to the data source
– It combines steps into a single statement that is sent to a data source
– Some operations may prevent query folding from happening
– It is supported by SQL Server
– Also supported by relational data sources

What it is NOT
– This is Not Available with all data sources

To see the steps, Enter into your Advanced Editor. It will show you the M Language here.

To view the SQL Server code that is generated:
In Power Query > Applied Steps section
Right click on a step, and select View Native Query
This will show you the SQL Server Code that will be sent back to the server for that particular step. However it does not sent the code back to SQL Server after each step. It sends it at the end when you Apply or Close & Apply

ADDING CUSTOM COLUMNS IN POWER BI

  • Power BI

I have been scraping Wikipedia for islands information, and building models in Power BI around them. One thing that I run into over and over is the lack of a certain field in each of the scrapes. The scraped don’t have the name of the State associated with the island names. So I will have to fix this by adding custom columns in Power BI / Power Query, so my models have better visuals. To do this you will need to perform the following:

Click Transform data to open Power Query Editor
Select Add Column from the Main Menu
Click Column From Examples
Select From All Columns
Enter in a value – for me I put in NH, and press Enter
Enter in your value a second time…for me it was placing NH in the second row, Now the rest of the rows should auto populate with the data (again for me NH showed in every subsequent row)
Click OK
Rename the leader from Literal, to State

You are done! Thanks for reading

POWER BI IMPORT VS DIRECT QUERY

  • Power BI

Import is taking a copy of a data from SQL server, and the copy is placed into your Power BI Desktop file

Direct Query leaves the data at the source and only pulls the data needed, when it is needed

CREATING A LOCAL MSSQL SERVER ON YOUR W10 PC

From time to time you will need to utilize a local sql server, for dev, testing, education, whatever. So here is a quick how-to on creating a local mssql server on your W10 pc.

Download and install the free version of SQL, called SQL Express:
https://www.microsoft.com/en-us/sql-server/sql-server-downloads
Accept all the defaults, except for these few
Use your credentials when prompted
Select all packages to be installed

Once SQL Express is installed, download and install SQL Server Management Studio
https://aka.ms/ssmsfullsetup

Now you have both installed, open SQL Server Management Studio or SSMS for short, and connect to your local SQL Express Database
Connect to “localhost\sqlexpress
You dont have to put in any credentials if you selected to use your credentials earlier.

To do a test on the database, try restoring the AdventureWorksDW database
Right click on Databases
Select Restore database
Select the AdventureWorksDW file
Click Ok

You can now connect into your database using Power BI or another tool, and start playing around.

Thanks for reading

WINDOWS 10 VM DISK INTEGRITY


This is a quick way to check the integrity of the local disk of a Windows 10 VM, that sits on an ESXi 6.7 Host

Go to the Type here to search box
Type cmd
Best Match will show Command Prompt
Select Run as administrator
Type in chkdsk C: /f /r /x

Check disk will now run and scan your system. If any errors come up, you will be notified, and can choose a course of action.

POWER BI INSTALL & PREVIEW FEATURES

  • Power BI

There are several ways to install Power BI, however the recommended Power BI Install is by going through the Microsoft Store. The reason behind it is, if you install it through the Store, it will auto update monthly. Yes Power BI updates the platform that often, and you will have the latest and greatest version.

Once it is installed, and after the monthly updates you will need to enable the Preview Features. To do this, perform the following:
Click File
Select Options and settings
Click Options
Select Preview features
Place a check mark next to All of them
Restart Power BI Desktop

You have now installed the platform and enabled the extra features.

Thanks for reading

RESTORE MINING WALLETS IN WINDOWS 10

The most recent Windows 10 update, went through my computer and started tagging many of my crypto wallets as threats, then it automatically quarrantined them. HUGE FAIL by Microsoft. I did not want their Defender app enabled after the update. I did not want it to scan my system.

To restore your newly quarrantined items, do the following:

Open Windows Security
Select Virus & threat protection
Click Protection history
In the list of all recent items, filter the Quarantined Items
Click all of the newly identified and restore

That’s it! Thanks for reading

SSH On My RASPBERRY PI 4

This is a quick one. I needed ssh on my Raspberry Pi 4, and this is how I did it

Turn on the Pi

Once on the Desktop, click on the Terminal icon

Type:
sudo bash
apt-get update
apt-get install openssh-server
y

Once that installs successfully
systemctl enable ssh
systemctl start ssh

That’s it. You can now login remotely to your pi through ssh



Thanks for reading

Hardware that I used:
Raspberry Pi 4 (4gb)
https://amzn.to/3q551IO

SanDisk 32GB Ultra microSDHC UHS-I Memory Card with Adapter
https://amzn.to/2Vfvo0y

CanaKit 3.5A Raspberry Pi 4 Power Supply (USB-C)
https://amzn.to/3fNTYPu

CanaKit Raspberry Pi 4 Micro HDMI Cable – 6 Feet
https://amzn.to/33u5hr9

Western Digital 500GB WD_Black SN750 NVMe
https://amzn.to/3nZ5pH4

Plugable USB C to M.2 NVMe Tool-free Enclosure
https://amzn.to/3lflV3L