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
simardd
New Member

Help!!!! Looking for the proper dax function to come up with this table

Hi,
I have data like this (see below)
data.png


And would like to have a Dax query in Power Bi to have the output like this: (See below)
Help!! 

output.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

First, I'd learn about PROPER MODEL DESIGN (star schema).

 

Second, I'd denormalize the table (unpivot it in Power Query).

Then, I'd create a Date table the way it should be and connect it to the main table (with the names).

Then, I'd write a very simple DAX measure to compute what you want.

 

The table, Actions, would be:

 

Name,Action,Date

Name1,Senttweet,7/13/2019

Name2,Senttweet,7/7/2019

...

 

Then you'd have the Date table and would join it to the above on the Date field (which would be present in both tables). The Date table must be A PROPER DATE TABLE (not just any table, please read about a proper date table in Power BI).

 

If you do the above, then your DAX will be clean, fast and easy to understand/maintain. It'll be this:

 

[Qty] = COUNTROWS( Actions )

-- add 0 to this to show 0's instead of BLANKS, like this:

[Qty] = COUNTROWS( Actions ) + 0

You then should hide the Date column in the Actions table and slice by time only using the Date table.

 

Best

Darek

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

First, I'd learn about PROPER MODEL DESIGN (star schema).

 

Second, I'd denormalize the table (unpivot it in Power Query).

Then, I'd create a Date table the way it should be and connect it to the main table (with the names).

Then, I'd write a very simple DAX measure to compute what you want.

 

The table, Actions, would be:

 

Name,Action,Date

Name1,Senttweet,7/13/2019

Name2,Senttweet,7/7/2019

...

 

Then you'd have the Date table and would join it to the above on the Date field (which would be present in both tables). The Date table must be A PROPER DATE TABLE (not just any table, please read about a proper date table in Power BI).

 

If you do the above, then your DAX will be clean, fast and easy to understand/maintain. It'll be this:

 

[Qty] = COUNTROWS( Actions )

-- add 0 to this to show 0's instead of BLANKS, like this:

[Qty] = COUNTROWS( Actions ) + 0

You then should hide the Date column in the Actions table and slice by time only using the Date table.

 

Best

Darek

Thanks so much!

After I have unpivoted those columns ('action'), it all made sense and was easy! (I am new to Power Bi)

thanks again.


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.

Top Solution Authors