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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Bar Chart using only data entrys with highes Value

I have a small data set ("Sheet1") that contains transactions. A transaction is definied by a customer who buys something - however it is not important who sold the product. The seller column is called "used in company".

 

Each transactions has a Transcation ID ("Tx-ID") and is associated with a Quantity of sold products ("Quantity"), a special profitability measure ("affordability") and a basic CM1 value ("CM1"). Customer and product info is not included. 

Now, since transactions can have different sellers (or "used in companies") - some transactions occur multiple times in the data set. These double transactions differ only in the affordability and CM1.

When working with the data, only those transactions with the highest affordability should be considered. However, this should be done with regards to one or multiple used in companies that the user has selected.

As an example, we have the following line items:

Affordabilityused in companyTx-IDQuantityCM1month
230New York13001000January
10Berlin1300200January
20Berlin24002000January

 

For used in company = New York & Berlin, CM1=3000 and Quantity = 700.

For used in company = Berlin, CM1 = 2200 and Quantity = 700

 

Now what I want to do is create a stacked bar chart, with:

- Y-Axis: CM1

- X-Axis: month & Tx-ID (to show a consolidated picture while still allowing for a drill down)

- Legend: Used in company

 

So sticking to the example from above:

 

On the consolidated monthly view, having all companies selected, the chart should display CM1 of 3000 (since only the CM1 associated with the higest affordability per Tx-ID is considered) with a 2000:1000 split.

When jumping to the Tx-ID level, I want to see two Transactions, where Tx-ID 1 belongs to New York and Tx-ID 2 belongs to Berlin.

 

This chart should also be adaptive to a "used in company"-slicer: Thus, used in company = Berlin, Tx-ID 1 as well as Tx-ID 2 should be associated with Berlin (since now for both transactions Berlin has the highest affordability) and on a consolidated view, the CM1 should be 2200.

 

How can I achieve that?

 

Thanks a lot for some wise advice!

1 ACCEPTED SOLUTION

Hi @Anonymous 

Just modified the measure to the following code

Measure = var a=MAXX(FILTER(ALLSELECTED('Table'),[Tx-ID] in VALUES('Table'[Tx-ID])&&[month] in VALUES('Table'[month])),[CM1])
return IF(ISFILTERED('Slicer'[used in company]),IF(COUNTROWS(VALUES(Slicer[used in company]))=CALCULATE(DISTINCTCOUNT('Table'[used in company]),ALL('Table')),CALCULATE(SUM('Table'[CM1]),FILTER('Table',[CM1]=a)),CALCULATE(SUM('Table'[CM1]),FILTER('Table',[used in company] in VALUES('Slicer'[used in company])))),CALCULATE(SUM('Table'[CM1]),FILTER('Table',[CM1]=a)))

vxinruzhumsft_0-1692605612395.png

 

vxinruzhumsft_1-1692605622639.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks a lot for the reply. Its a good start but not exactly what I was looking for yet.

 

I your shared solution, when I select all used in companies, all three transactions are considered in the chart. However, when I select New York and Berlin, it should be checked if they share a Tx ID (which they do, Tx ID = 1) and if so, display only the one with the highest affordability (so in this Case the New York transaction).

 

And the same then also holds on the consolidated monthly view.

 

sbue_1-1692602167551.png

sbue_2-1692602254551.png

 

Hi @Anonymous 

Just modified the measure to the following code

Measure = var a=MAXX(FILTER(ALLSELECTED('Table'),[Tx-ID] in VALUES('Table'[Tx-ID])&&[month] in VALUES('Table'[month])),[CM1])
return IF(ISFILTERED('Slicer'[used in company]),IF(COUNTROWS(VALUES(Slicer[used in company]))=CALCULATE(DISTINCTCOUNT('Table'[used in company]),ALL('Table')),CALCULATE(SUM('Table'[CM1]),FILTER('Table',[CM1]=a)),CALCULATE(SUM('Table'[CM1]),FILTER('Table',[used in company] in VALUES('Slicer'[used in company])))),CALCULATE(SUM('Table'[CM1]),FILTER('Table',[CM1]=a)))

vxinruzhumsft_0-1692605612395.png

 

vxinruzhumsft_1-1692605622639.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

v-xinruzhu-msft
Community Support
Community Support

Hi @Anonymous 

You can refer to the following example

The data table is the same as your offered.

Slicer table

vxinruzhumsft_0-1692597519885.png

 

Then you can create a measure and put the measure to y-axis

Measure = var a=CALCULATE(MAX('Table'[Tx-ID]),ALLSELECTED('Table'),'Table'[used in company] in VALUES('Table'[used in company]))
return IF(ISFILTERED('Slicer'[used in company]),CALCULATE(SUM('Table'[CM1]),FILTER('Table',[used in company] in VALUES('Slicer'[used in company]))),CALCULATE(SUM('Table'[CM1]),FILTER('Table',[Tx-ID]=a)))

Output

vxinruzhumsft_1-1692597684682.png

 

vxinruzhumsft_2-1692597707336.png

 

vxinruzhumsft_3-1692597715590.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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