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
thmonte
Helper IV
Helper IV

How to use same data over 3 columns

I have a dataset very similar to below

 

idcode 0code 0 timecode 1code 1 timecode 2code 2 timelast_time
1AA1/21/2018 21:35CC1/20/2018 21:35  1/24/2018 21:35
2BB1/18/2018 21:35AA1/21/2018 21:35CC1/14/2018 21:351/24/2018 21:35
3CC1/15/2018 21:35    1/24/2018 21:35
4DD1/14/2018 21:35AA1/18/2018 21:35BB1/21/2018 21:351/24/2018 21:35

 

And I want to get some averages and counts over each of these columns. Each 'code' column is all the same data just spread out over all 3. How can I get a count for example of how many times a code appears in all 3 columns in my data set. So I have a unique set of codes and a count of how many times they appear. From there I should be able to get the averages pretty easily.

 

CODE Count
AA3
BB2
CC3
DD1

 

In addition to that I want to get some average times between each Code

 

So each code has a time I want to compare that time to 'last_time' and return a value ex. 4 days

 

and then get an average of time difference for each distinct code

 

I never really had to reiterate my DAX over multiple columns like this so any info would be very helpful!!

 

Thanks as always - great community here

2 ACCEPTED SOLUTIONS
GilbertQ
Super User
Super User

Hi @thmonte

 

What I would do, is to make each part of your data a seperate dataset. So you would have 3 tables one for code 0, code 1 and code 2

 

I would then append them all together, so that it formed one long table. You would be able to know which table belongs to which code, by adding in an extra column on each dataset with the CodeID.

 

That would then allow you to easily get your distinct count.

And if you ordered the data by the time, you would then also be able to do the time calculations between the columns.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

Ashish_Mathur
Super User
Super User

Hi @thmonte,

 

I have solved this exact problem - Restructure the layout of datasets.  Look at Case 1.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi @thmonte,

 

I have solved this exact problem - Restructure the layout of datasets.  Look at Case 1.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for the response @Ashish_Mathur - I am going to mark this closed as I did reshape my data to get a row for each "code"

 

I now move on to a new issue of referencing other rows based on conditions and using a value in that row for TIMEDIFF.  This one is going to be tricky.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
GilbertQ
Super User
Super User

Hi @thmonte

 

What I would do, is to make each part of your data a seperate dataset. So you would have 3 tables one for code 0, code 1 and code 2

 

I would then append them all together, so that it formed one long table. You would be able to know which table belongs to which code, by adding in an extra column on each dataset with the CodeID.

 

That would then allow you to easily get your distinct count.

And if you ordered the data by the time, you would then also be able to do the time calculations between the columns.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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.