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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
UsePowerBI
Post Prodigy
Post Prodigy

Problem to create table and graph

Hello

 

Can you try inputting the following data please in a pbix and help me overcome the issues?

 

Table1:

ID; CATEGORY;
A1; A;
A2; A;
A3; A;
B1; B;
B2; B;

 

Table2:
ID; NUMBER OF ITEMS
A1; 1
A2; 10
A3; 3
B1; 2
B2; 1

 

I want to create a table visual in the following format:

CATEGORY; ID; TOTAL ITEMS

 

The TOTAL ITEMS is the following MEASURE:

TOTAL ITEMS = IF(SELECTEDVALUE(Table1[CATEGORY])="A",
CALCULATE(COUNTROWS(Table2),FILTER(Table2,Table2[ID]=SELECTEDVALUE(Table1[ID])),Table2[NUMBER OF ITEMS]<>1),
IF(SELECTEDVALUE(Table1[CATEGORY])="B",
CALCULATE(COUNTROWS(Table2),FILTER(Table2,Table2[ID]=SELECTEDVALUE(Table1[ID])),Table2[NUMBER OF ITEMS]=<>2),
BLANK()))

 

 

So the result in the table visual should be:

CATEGORY; ID; TOTAL ITEMS

A; A1; 0/blank

A; A2; 1

A; A3; 1

B; B1; 0/blank

B; B2;  1

 

I also want to create a graph that will show in x axis the Category and in y axis the SUM of the TOTAL ITEMS as displayed in the table visual above (CATEGORY; ID; TOTAL ITEMS).

So the values in the graph would be:

bar1 = A and 2

bar2 = B and 1 

 

Thanks!

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @UsePowerBI ,

 

You may create [SUM of the TOTAL ITEMS] using measure like DAX below, and put it into Values box of chart visual.

 

SUM of the TOTAL ITEMS= SUMX(VALUES([CATEGORY]), [TOTAL ITEMS] )

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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
v-xicai
Community Support
Community Support

Hi @UsePowerBI ,

 

You may create [SUM of the TOTAL ITEMS] using measure like DAX below, and put it into Values box of chart visual.

 

SUM of the TOTAL ITEMS= SUMX(VALUES([CATEGORY]), [TOTAL ITEMS] )

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

parry2k
Super User
Super User

@UsePowerBI logic for Total Items is not clear, can you explain the logic how you are getting to those numbers, what is the business logic?



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.

Hello @parry2k 

 

Sorry about that. I did not put the names of the columns/measures to represent my business case for anonymity.

 

Please find the pbix here: https://ufile.io/pek51r0j (I posted to another thread but I suppose you will only look here)

 

What I want to create is a graph with y axis to be the KPIs and y axis the SUM of the NO OF TRANSACTIONS.

 

Can you tell me please how to do that? Thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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