# Showcasing Microsoft Fabric Ecosystem: Exploring Semantic Link and Data Analysis Capabilities

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729403821253/7864a8bf-ec7f-4905-8b56-c436d5a8bb06.png align="center")

Hey there, data enthusiasts! Today, we're going to take an exciting journey through the Microsoft Fabric ecosystem, focusing on some powerful tools and techniques for data analysis. We'll be looking at code snippets that demonstrate how to use Semantic Link, explore datasets, and perform various analytical tasks.

In this post, we'll cover:

* Setting up the environment
    
* Exploring the Fabric workspace
    
* Diving into datasets
    
* Exploring relationships
    
* Counting tables and columns
    
* Working with measures
    
* Filtering data
    
* Using advanced analysis tools
    

By the end of this journey, you'll have a solid grasp of how to navigate and leverage the Microsoft Fabric ecosystem for your data analysis needs. So, buckle up, and let's dive in!

## Setting Up Our Environment

First things first, we need to import the necessary libraries. We'll be using `sempy.fabric` for most of our Fabric-related operations, along with some additional modules for relationship analysis and visualization.

> For Spark 3.4 and above, semantic link is available in the default runtime when using Fabric, and there's no need to install it.

```python
import sempy.fabric as fabric
from sempy.relationships import plot_relationship_metadata, find_relationships
from sempy.fabric import list_relationship_violations
import pandas as pd

# A little trick to make our output look nicer
import pandas as pd
pd.set_option('display.max_colwidth', None)
```

## Exploring Your Fabric Workspaces

Let's start by getting a lay of the land. We can use the `list_workspaces()` function to see all the workspaces we have access to:

```python
fabric.list_workspaces()
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404187924/82ae68ff-87e7-43ea-89c8-4142a9a8ad04.png align="center")

This will give you an overview of your Fabric environment. It's like opening up your file explorer to see all your folders!

## Diving into Datasets

Now that we know where we are, let's see what datasets we have to play with:

```python
fabric.list_datasets()
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404218761/001ed7cd-2b66-45d9-b740-14970adf860d.png align="center")

This function will show you all the datasets available in your current workspace. Think of it as peeking into each folder to see what files you have.

## Exploring Relationships

Relationships are the backbone of good data modeling. Let's take a look at the relationships in a specific dataset:

```python
dataset = "Understanding DAX Auto-Exist"
relationships = fabric.list_relationships(dataset)
relationships
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404246738/d1284e11-9e71-4c28-acf5-ce67af7735c4.png align="center")

This will give you a list of all the relationships in the "Understanding DAX Auto-Exist" dataset. But wait, there's more! We can visualize these relationships:

```python
plot_relationship_metadata(relationships)
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404268435/c91d458e-5fa0-43f3-9adf-50a81e7c6c63.png align="center")

This will create a neat diagram showing how your tables are connected. It's like drawing a map of your data!

## Counting Tables and Columns

Want to know how many tables you have and what columns are in each? We've got you covered:

```python
ds = "Computing rolling average in DAX - sample"
fabric.list_tables(dataset=ds, extended=True)
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404299703/bf512894-ab79-44ec-918f-3070212ad5e8.png align="center")

This will give you a detailed list of all tables in the dataset. But let's go deeper and look at the columns in a specific table:

```python
fabric.list_columns(dataset=ds, extended=True, table="Product")
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404345422/bf1615c0-2d97-466d-be83-e7439f277b28.png align="center")

Now you can see all the columns in the "Product" table. It's like getting a detailed inventory of your data!

## Working with Measures

Measures are the calculations that bring your data to life. Let's see what measures we have:

```python
fabric.list_measures(dataset)
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404384482/29c72525-7a4f-443d-b7f3-f1cd7ee91502.png align="center")

But knowing they exist isn't enough. Let's evaluate a measure:

```python
fabric.evaluate_measure(dataset, measure="Sales Amount")
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404402827/4b35e4c0-30e4-4f18-8431-0e3b34e40568.png align="center")

This will calculate the "Sales Amount" measure for your entire dataset. But we can get more specific and group by based on required columns

```python
fabric.evaluate_measure(dataset, measure="Sales Amount", 
                        groupby_columns=["Product[Brand]", "Product[Color]"])
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404466601/2e518d87-ccf5-4b82-a223-52eaafc04326.png align="center")

Now we're calculating ‘Sales Amount’ for each combination of Brand and Color. It's like slicing and dicing your data to get exactly the view you need!

## Filtering Your Data

Sometimes you want to focus on specific parts of your data. Let's filter our Sales Amount:

```python
fabric.evaluate_measure(dataset, 
                        measure="Sales Amount", 
                        groupby_columns=["Product[Brand]", "Product[Color]"], 
                        filters={"Product[Brand]": ["A. Datum"], "Product[Color]": ["Azure"]})
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404495274/bf2617e6-e6d5-4672-b8cd-92894609c2c7.png align="center")

This will show you the ‘Sales Amount’ for just the ‘A. Datum’ brand and ‘Azure’ color. It's like using a magnifying glass to focus on one specific part of your data landscape!

## More Analysis Tools (Using Semantic Link Labs )

> Thanks [Michael Kovalsky](https://www.linkedin.com/in/michaelkovalsky/) and Team who made it so easy to achieve easier automation with these amazing extension package.
> 
> Semantic Link Labs is **a Python library designed for use in Microsoft Fabric notebooks**. This library <mark>extends the capabilities of Semantic Link</mark> offering additional functionalities to seamlessly integrate and work alongside it.
> 
> Reference : [https://github.com/microsoft/semantic-link-labs](https://github.com/microsoft/semantic-link-labs)

For those who want to go even deeper, Fabric offers some advanced analysis tools:

### *Best Practice Analyzer*

Not sure what it is?, Read and learn from [Here](https://docs.tabulareditor.com/te2/Best-Practice-Analyzer.html).

```python
import sempy_labs as labs

ds = "Computing rolling average in DAX - sample"
labs.run_model_bpa(dataset=ds)
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404552775/13811c0d-d314-4e37-b4e6-63d9d5dd552d.png align="center")

This now supports translation into multiple languages, including automatic translation of my native language, “Sinhala”❤️

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1730879431563/68b8bdc7-1fb9-4e7e-97b5-ec92632c9cd2.png align="center")

### *Vertipaq Analyzer (Read to know the* [*history of it)*](https://www.sqlbi.com/tools/vertipaq-analyzer/)

```json
ds="Computing rolling average in DAX - sample"
labs.vertipaq_analyzer(dataset=ds)
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729404937954/ff110b7d-af83-4aaf-bfed-69d15ea4ea07.png align="center")

These tools will give you an in-depth analysis of your data model, helping you optimize performance and understand your data better.

## Wrapping Up

<mark>We've just scratched the surface of what's possible with Microsoft Fabric and Semantic Link / Semantic Link Labs</mark>. From exploring your workspace and datasets to analyzing relationships and evaluating measures, these tools provide a powerful way to understand and work with your data.

Remember, the key to mastering these tools is practice. So don't be afraid to experiment, try different datasets, and see what insights you can uncover.

Happy data analyzing!
