March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi!
I need to create a Matrix visual (or a visual table looking that does the same thing) using 2 levels of hierarchy. This is the data:
And I need to display the total of all (that's easy), but below that just ONE of the companies (Nike in my example below) and then the cities, but showing the total amount including the items sold in the other company.
On the left you can see what I get, that it's Nike and within that level I have the cities, but what I want is the rigth picture that I made in excel as an example, which is one company and then the total per city in both nike and adidas.
Is there a way to make that possible?
Thank you in advance! 🙂
Solved! Go to Solution.
Hi @Anonymous ,
Please refer to my pbix file to see if it helps you.
Create a measure.
Measure =
VAR _value =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[City] = SELECTEDVALUE ( 'Table'[City] )
&& 'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
)
)
VAR _NIKE =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
&& 'Table'[City] = SELECTEDVALUE ( 'Table'[City] )
)
)
VAR result =
IF (
HASONEVALUE ( 'Table'[City] )
&& MAX ( 'Table'[Company] ) = "NIKE",
_NIKE,
IF (
HASONEVALUE ( 'Table'[City] )
&& MAX ( 'Table'[Company] ) = "Adidas",
_NIKE,
SELECTEDVALUE ( 'Table'[Value] )
)
)
VAR _a =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
&& 'Table'[Company] = SELECTEDVALUE ( 'Table'[Company] )
)
)
RETURN
IF ( HASONEVALUE ( 'Table'[City] ), result, _a )
If I have misunderstood your meaning, please provide more details with your desired output.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Please refer to my pbix file to see if it helps you.
Create a measure.
Measure =
VAR _value =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[City] = SELECTEDVALUE ( 'Table'[City] )
&& 'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
)
)
VAR _NIKE =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
&& 'Table'[City] = SELECTEDVALUE ( 'Table'[City] )
)
)
VAR result =
IF (
HASONEVALUE ( 'Table'[City] )
&& MAX ( 'Table'[Company] ) = "NIKE",
_NIKE,
IF (
HASONEVALUE ( 'Table'[City] )
&& MAX ( 'Table'[Company] ) = "Adidas",
_NIKE,
SELECTEDVALUE ( 'Table'[Value] )
)
)
VAR _a =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
&& 'Table'[Company] = SELECTEDVALUE ( 'Table'[Company] )
)
)
RETURN
IF ( HASONEVALUE ( 'Table'[City] ), result, _a )
If I have misunderstood your meaning, please provide more details with your desired output.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Sorry for the late response. I couldn't check the code until now.
That's exactly what I wanted!! I didn't think it could be possible, you are brilliant!
I really appreciate that you have taken the time to help me. 😊
Thank you very much! 😊
@Anonymous well should explain the logic based on sample data. as I asked, will the same happen for adidas?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k
Sorry, I didn't understand your question the first time (English is not my mother language).
Yes, for Adidas would the same, the total for adidas and then the cities would have the same result as it's the sum of both again (here a pic of the result)
I hope I explained it properly now.
Thank you very much 🙂
@Anonymous why there is no adidas in the expected output?
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k
This is an example. In my real data, I need to show a category that would be "Nike" here, to show the total items sold no matter the city. The cities that appear below, if you see, they are the sum of both Nike an adidas items sold. For instance, Madrid is 400 (100+300) in the first column (Alicia).
Thank you 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
106 | |
98 | |
65 | |
54 |