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
AnandRanga
Helper III
Helper III

Group by in DAX ?

I have written a formula in powerbi that is total hours/Billable hours. There can be more than 2 billable hours but there can't be more than one total hour. Total hour will be same for one date. But the problem is that this formula will count all the values of total hour. I want to group by this column value.

How to write this expression in DAX?

In my table I am getting it using in built functions in but If I convert it into chart ,It's showing wrong results ? 

1 ACCEPTED SOLUTION

@AnandRanga You can achieve Group By using DAX as below. Under Modelling tab click New Table and use below code to get output in the form of second table of your screenshot.

 

Table = GROUPBY(TABLENAME,TABLENAME[date],TABLENAME[workinghours],"a",SUMX(CURRENTGROUP(), TABLENAME[hours]) )

View solution in original post

5 REPLIES 5
BhaveshPatel
Community Champion
Community Champion

Please post the sample data and expected output.Your explanation is bit hazy.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

@BhaveshPatel

This is the case

Capture.jpg

I want sum of hour field like for 16 sept - sum of hour will be 9 but for the working hours it should be 9 only. Now I am having this:

Capture2.jpg

but the problem is I have written a utilization % formula where I have written Total hours / working hours. So it should be 47.50/36. But It's calculating 47.50/72 (8 times 9, by previous table).

So I want to create a measure where I want to group by working hours by date.

Thanks for your time. 

@AnandRanga You can achieve Group By using DAX as below. Under Modelling tab click New Table and use below code to get output in the form of second table of your screenshot.

 

Table = GROUPBY(TABLENAME,TABLENAME[date],TABLENAME[workinghours],"a",SUMX(CURRENTGROUP(), TABLENAME[hours]) )

Anonymous
Not applicable

Hi,

Can we use two different tables in group by function? My columns are in different tables which I want to use in group by.

If that is not possible, then what could be the alternate way to group by which allows taking two tables? 

 

Thanks,

Janki 

how to do this in direct mode as new table column option is not available ?

 

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.