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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
shrafco1
Frequent Visitor

How to do many to many comparison in Power BI with the help of measures and calculated columns

https://drive.google.com/file/d/14eGL2MvLIakMMoY0JZoBliPZldCSr3Oa/view?usp=sharing (PBIX file).

Capture.PNGCapture1.PNGI have two dates column in my data set, Isolation Start Date & Isolation End Date. I have another column called Status which tells you wheather the indvidual get released or still in isolation. The problem is to count total number of people in isolation for each date based on isolation start date and isolation end date columns. I created calculated coulmn as follow

Isolation Time =
IF RELATED('Dim Date'[Date]) >= 'Isolation by Day'[Isolation Start Date] && RELATED('Dim Date'[Date]) <= 'Isolation by Day'[Isolation End Date]1).
Then I created a measure to sum up all the ones. Then, I put the measure and the date column in a column chart but the result is not what it required. I suppose to compare each isolation start date using  the formula above and save its result, which is comparing many dates in isolation start date column with other many dates in isolation end date. How to deal with this kind of comparison in Power BI. Takes each date and compare it using the formula and sum up the ones and save the result, then go to the next date do the same thing.  Thank you in advance
1 ACCEPTED SOLUTION

Please go through the steps in the Query Editor.


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

View solution in original post

5 REPLIES 5
shrafco1
Frequent Visitor

https://drive.google.com/file/d/14eGL2MvLIakMMoY0JZoBliPZldCSr3Oa/view?usp=sharing  (PBIX file)Capture.PNG

 

@amitchandak This is the table and a sample of the calculations. I just used Total for April 21 calculated column as example so you can understand what I need to do, so for each range of Isolatin start date and Isolation end date check if contains April 21 put 1, then I sumed up all the ones, the total is 10. However, I wanted to do this calculation for each date in Isolation Start Date column. so I created a measure called Total # of isolation per day as you can see it in the screen shot below and I tested in a column chart  but it did not work correctly. You can see it below for example, the total number of isolation for April 21 in the card is 10 but when I used the measure Total # of isolation the result was only 5.  You can also check the PBIX file in the link above.

Capture1.PNG  

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

Hi @Ashish_Mathur, thank you for the help, could you please explain what changes you made in Power query, I could not see it because of the error in the data. but I see the number of records are increased and no isolation start date and end date columns

 

Thank you  

Please go through the steps in the Query Editor.


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

@shrafco1 ,Not very clear to me.

Refer if this can help

https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 


Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.