Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Quenjo
Helper II
Helper II

Get the values to the corresponding lines in a matrix

Hi community,

 

I created a Matrix that has three lines :

 

+Company

   +Server

      +Database

 

I want to do some calculations based on the specifications of the servers and the databases but not the company.

 

Let me take an example :

 

For the company line in the matrix I only want to have the Company Name.

Then, when I expand the company I have all the servers related to the concerned company. These server have a certain number of CPUs, of disk space, in brief, of specificities.

 

I would have only all the specificities "deployed" only and only when I expand a company, not always.

 

Let me show some screenshots :

 

Quenjo_0-1654092859346.png

 

As you can see here, I have the company name :

 

Quenjo_1-1654092916198.png

 

And the sum of all the specificities of all the servers belonging to this company. I do not want this "general" view.

How is it possible to have all the specificites deployed only for the concerned servers / concerned databases ?

 

Don't hesitate if it is not clear enough and you need more explanations !

 

Thanks for your help.

 

Best regards,

Jonathan

 

 

1 ACCEPTED SOLUTION

@Quenjo 
Yes this is true. ISINSCOPE means if filtered by. All the levels below or equal to "company" for example are filtered by company therefore, eveything returns "True". This is why the order of the SWITCH arguments is essential to get the correct results. Usually we start from the bottom level up to the top level. 

View solution in original post

16 REPLIES 16
tamerj1
Super User
Super User

Hi @Quenjo 

I don't know about other methods that do not include DAX. 

If you are summarizing columns in the visual then you need to replace them with measures. Example measure would be 

Measure =
IF ( NOT ISINSCOPE ( TableName[Company Name], SUM ( TableName[Comulmn1] ) )

Hi @tamerj1,

 

Thanks for the reply. However, this will only give the SUM of the disk_space column and this is not what I am expecting.

 

Let me explain it better :

 

Quenjo_0-1654171625282.png

Here, I just want to have the 830 displayed in the same line as the server, and the "microsoft_sql_server" displayed in the same line as the database. Nothing should be displayed under the company.

 

If everything is always displayed, I will have something like this in the PowerBi "Homepage" :

 

Quenjo_1-1654171737502.png

The bofuscated field is the company name, the 156'260 represents the disk_space and the mssql server represents the database type. You understand that it makes no sense to just take the first type of database related to a company. I just want this information to be displayed under the column related to each database.

 

Hope you understand my issue. How can I solve this ?

 

Many thanks,

Jonathan

@Quenjo 
Would you please share the code that you've tried?

@tamerj1 ,

 

Espace disque = IF ( NOT ISINSCOPE ( company[Company Name]), SUM ( servers[disk_space] ) )
Quenjo_0-1654172494713.pngQuenjo_1-1654172506571.png

It just prints the total of the whole disk space of all servers without displaying the companies anymore.

 

Thanks for your help, @tamerj1 

@Quenjo 
Please try

Espace disque =
SWITCH (
    TRUE (),
    ISINSCOPE ( company[Database Name] ), SUM ( servers[disk_space] ),
    ISINSCOPE ( company[Server Name] ), SUM ( servers[disk_space] )
)

@tamerj1 

 

It does not work since I do not have the Database Name in the company table.

If I try to put something like this :

 

Espace disque =
SWITCH (
TRUE (),
ISINSCOPE ( databases[DB Name] ), SUM ( servers[disk_space] ),
ISINSCOPE ( servers[Server Name] ), SUM ( servers[disk_space] )
)

 

It does not work too... I really can not find a solution to this issue.

 

I tried to only put :

 

Espace disque = ISINSCOPE( servers[Server Name] )

 

And this works, since only the server line is set as True and the company and database line are set as False.

@Quenjo  😂

So you have multiple tables? Can you please give more details about your data model and relationships?

@tamerj1  Sure !

 

Quenjo_0-1654174812024.png

 

 

Hope thos helps. The Server table has a foreign key to the company Id (primary key) and the Database table has a foreign key to the server Id (primary key).

 

Hope this helps you out !

@Quenjo 
Try with HASONEVALUE

Espace disque =
SWITCH (
    TRUE (),
    HASONEVALUE ( databases[DB Name] ), SUM ( servers[disk_space] ),
    HASONEVALUE ( servers[Server Name] ), SUM ( servers[disk_space] )
)

@tamerj1 

 

It does not work.

 

Forget the databases table. The databases has not the disk_space, only the servers table contains disk_space. So, I want to display only the disk_space only for each server line when expanding a company.

 

The ISINSCOPE function seems to be right since the result of it is the following :

 

Quenjo_0-1654182091578.png

 

Where the "False" values represent the companies and the "True" values represent the servers. However, I do not understand how I can display the concerned column only and only for the "true" fields.

@Quenjo 

My apologies. I misunderstood your requirement. Please try

 

 

Espace disque =
SWITCH (
    TRUE (),
    ISINSCOPE ( databases[DB Name] ), BLANK (),
    ISINSCOPE ( servers[Server Name] ), SUM ( servers[disk_space] ),
    ISINSCOPE ( Company[Company Name] ), BLANK ()
)

 

 

@tamerj1 

 

No problem, you are trying to help and I really appreciate it !

When using your last formula I have the following :

Quenjo_0-1654238164357.png

 

Edit : While doing some tests, I found out that with your formula it works when expanding a company. In the sense that, in this formula we are saying :

 

if isinscope company Name then BLANK. So, the thing is, here nothing will be displayed. How can I say that if company name isinscope it will just display the company name and not blank ? Hope you understand.

 

Edit 2 : I found an interesting thing :

 

Quenjo_0-1654243617307.png

 

It seems that everything that is below the company name is in scope of the company name. Because we are saying that everything that is in scope of the company name must be BLANK. Nothing will be displayed. Any idea to avoid this ?

 

 

Any idea ?

 

 

 

@Quenjo 
Yes this is true. ISINSCOPE means if filtered by. All the levels below or equal to "company" for example are filtered by company therefore, eveything returns "True". This is why the order of the SWITCH arguments is essential to get the correct results. Usually we start from the bottom level up to the top level. 

@Quenjo 
😂🤣😂🤣

Yes it is confusing specially without having the data in front t of your eyes. I hope this will finally work

Espace disque =
SWITCH (
    TRUE (),
    HASONEVALUE ( databases[DB Name] ), BLANK (),
    HASONEVALUE ( servers[Server Name] ), SUM ( servers[disk_space] ),
    HASONEVALUE ( Company[Company Name] ), BLANK ()
)

@tamerj1 ,

 

Can you look at my Edit 2 ? It should really help us to find the solution to the problem.

@Quenjo 
Like this?

Espace disque =
SWITCH (
    TRUE (),
    HASONEVALUE ( databases[DB Name] ), BLANK (),
    HASONEVALUE ( servers[Server Name] ), SUM ( servers[disk_space] ),
    HASONEVALUE ( Company[Company Name] ), SELECTEDVALUE ( Company[Company Name] )
)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.