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
wadda7
Helper I
Helper I

calculate value with condition and group by

Hi 

 

I have transaction table with items  

i want to get the count of each itemid if the status = 0 and category = 3 and it should be  group by itemid and locationid in new table

 

it should be like this 

wadda7_0-1610998081318.png

 

 

 

 

1 ACCEPTED SOLUTION
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @wadda7,

 

please find below a possible solution.

 

old table (t_6):

picture_1.PNG

 

formula:
t_6_new = GROUPBY(
FILTER(t_6,t_6[status]="0" && t_6[category]="3"),
t_6[ID],t_6[location],
"count",
COUNTX(CURRENTGROUP(),t_6[ID]))

 

result (t_6_new):

picture_2.PNG

 

Best regards

Mikelytics

 

Did I solve your request? Please mark my post as solution

 

Appreciate your Kudos.

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

9 REPLIES 9
wadda7
Helper I
Helper I

and also should be group by maintable[itemid] and maintable[locationid]

Mikelytics
Resident Rockstar
Resident Rockstar

Hi @wadda7,

 

please find below a possible solution.

 

old table (t_6):

picture_1.PNG

 

formula:
t_6_new = GROUPBY(
FILTER(t_6,t_6[status]="0" && t_6[category]="3"),
t_6[ID],t_6[location],
"count",
COUNTX(CURRENTGROUP(),t_6[ID]))

 

result (t_6_new):

picture_2.PNG

 

Best regards

Mikelytics

 

Did I solve your request? Please mark my post as solution

 

Appreciate your Kudos.

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

work fine with me thank you 

wadda7_0-1610999786054.png

this error comes 

itemid = text

inventdimid (location) = text 

status = int

category = int 

@wadda7 

 

since your status and category is int you have to make [status] = 0 && [ category] = 3 without using the ""

 

 

Did I solve your request? Please mark my post as solution

 

Appreciate your Kudos.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

^Please check if the columns you are use in the filter are formatted as text or number.

 

if it is number you do [column] = 1

if it is text you do [column] = "1"

 

Best regards

Mikelytics

 

Did I solve your request? Please mark my post as solution

 

Appreciate your Kudos.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

 

Hi @wadda7 ,

 

you could do this e.g. with the following measure

 

count status 0 = COUNTX(maintable, IF(maintable[status] = 0, 1 , BLANK()))

 

Count_Status_0.png

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


i want 2 condtions staus = 0 and category = 3 how to add the second condtion 

 

Hi @wadda7 

count status 0 = COUNTX(maintable, IF(maintable[status] = 0 && maintable[category] = 3, 1 , BLANK()))

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


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.