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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
sivarajan21
Post Partisan
Post Partisan

Filter context playing up with Calculated column logic

Hi Team,

 

I have a calculated column as below:

sivarajan21_6-1740654499806.png

 

Its working fine in this table level. But when I use this column in a table visual in report its not working correctly and its giving 'Yes' in all rows of the table for same deviceid: FYR, screenshot attached(Will be happier if this logic is pushed into Power query for better performance):

sivarajan21_5-1740654452818.png

It should contain only rows where there are warnings(Yes).

 

But when i remove the OpenMinutes,Storetime and Door Time from above table, I get the correct output:

sivarajan21_2-1740652107045.png

My expected output columns for filtered sitecode 73 and deviceid 2452 is i need below columns along with Store Time, Door Time and OpenMinutes.

 

sivarajan21_3-1740652239313.png

Store Time comes from Openstateduration table DateTimeRounded which is linked to Door table DateTimeRounded(Both date columns should match):

sivarajan21_9-1740655585693.png

 

Door Time will be coming from Createdon date of Openstateduration table which is linked to Door table Createdon(Both date columns should match):

sivarajan21_8-1740654642268.png

 

Modeling for these tables are:

sivarajan21_10-1740656444335.png

Could you please help me fix this issue? Also, much appreciated if you help me with alternative or better solution like pushing Warning logic to power query or creating better modeling for this issue etc.

 

PFA file here B&M (4).pbix

Please feel free to let me know if any issues!

 

Thanks in advance!

@Ahmedx @marcorusso @tharunkumarRTK @v-zhengdxu-msft @ray_aramburo 

1 ACCEPTED SOLUTION
ray_aramburo
Super User
Super User

Hi @sivarajan21  the issue further than the measures lies in the semantic model design. You have multiple "Yes" due to ambiguous relationship tha the context has. Example: You have a 02/27/2025 9:30:00 AM date which has N rows due the Updates column, the N number of stores and N number of Devices, that's ok, it's a fact table, but then, the Warnings table comes from another mini facts table itself as it has a list of N number of devices which have N number of logs. If you have as an example 

Log ID Store ID Device ID DateRounded Update Date
1 17 5000 02/27/2025 9:30:00 AM 02/27/2025 9:35:00 AM
2 17 5000 02/27/2025 9:30:00 AM 02/27/2025 9:45:00 AM
3 17 5000 02/27/2025 9:30:00 AM 02/27/2025 9:55:00 AM

And then you have a log for the warnings of devices such as (see table below)

 

ID Device ID Date Rounded Closed On Warning
34 5000 02/27/2025 9:30:00 AM 02/27/2025 9:36:00 AM Yes
35 5000 02/27/2025 9:30:00 AM 02/27/2025 9:38:00 AM No

 

What will happen is that since the device log doesn't have a store key for those specific times, when producing the results, the model doesn't know how to distribute the resulting values, thus, repeating and spreading them across the visual. To solve this you need a composite key involving Store/Site - Device ID - Time - Log ID .

Additionally, you are creating measures for situations that would be best addressed upstream or directly in Power Query such as calculating the Site Name, getting the Breach tying the store dates and device dates. 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





View solution in original post

6 REPLIES 6
ray_aramburo
Super User
Super User

Hi @sivarajan21  the issue further than the measures lies in the semantic model design. You have multiple "Yes" due to ambiguous relationship tha the context has. Example: You have a 02/27/2025 9:30:00 AM date which has N rows due the Updates column, the N number of stores and N number of Devices, that's ok, it's a fact table, but then, the Warnings table comes from another mini facts table itself as it has a list of N number of devices which have N number of logs. If you have as an example 

Log ID Store ID Device ID DateRounded Update Date
1 17 5000 02/27/2025 9:30:00 AM 02/27/2025 9:35:00 AM
2 17 5000 02/27/2025 9:30:00 AM 02/27/2025 9:45:00 AM
3 17 5000 02/27/2025 9:30:00 AM 02/27/2025 9:55:00 AM

And then you have a log for the warnings of devices such as (see table below)

 

ID Device ID Date Rounded Closed On Warning
34 5000 02/27/2025 9:30:00 AM 02/27/2025 9:36:00 AM Yes
35 5000 02/27/2025 9:30:00 AM 02/27/2025 9:38:00 AM No

 

What will happen is that since the device log doesn't have a store key for those specific times, when producing the results, the model doesn't know how to distribute the resulting values, thus, repeating and spreading them across the visual. To solve this you need a composite key involving Store/Site - Device ID - Time - Log ID .

Additionally, you are creating measures for situations that would be best addressed upstream or directly in Power Query such as calculating the Site Name, getting the Breach tying the store dates and device dates. 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





Hi @ray_aramburo ,

 

Sir  it means a lot to me and i will close this query

I have tried as you said and it helped me atleast for now to get a solution

My output:

sivarajan21_0-1740720684890.png

As per your suggestion i created a key column combined them using Siteid-Deviceid-Createdon datetime-Logid 

sivarajan21_1-1740720795757.png

then created one-one between both

sivarajan21_2-1740720820458.png

 

Many thanks sir!

Hi @ray_aramburo sir,

 

Thanks for your quick response and taking time to look into it! one need a lot of patience to look into the community and solve others problem. Hats off!

You are my only hope to solve this scenario! I need to submit this report by EOD today. 

But am confused how to achieve the below sir:

 

"To solve this you need a composite key involving Store/Site - Device ID - Time - Log ID .

Additionally, you are creating measures for situations that would be best addressed upstream or directly in Power Query such as calculating the Site Name, getting the Breach tying the store dates and device dates"

 

Please can you help on how to achieve the below?

You small help is much appreciated

 

Thanks in advance!

@ray_aramburo @marcorusso @tharunkumarRTK 

sivarajan21
Post Partisan
Post Partisan

Good Day! 

Just to confirm, have you had a chance to look into this? I know you might be busy but if you can help me with above its much appreciated.
As my clients have given a deadline for tonight, I would greatly appreciate your quick insights on resolving this issue. Your expertise would be immensely helpful in finding a solution
The issue I am facing is that my report visual should contain only rows where there are warnings ("Yes") and not other rows. I don't why it gives yes in all rows.

many thanks in advance!
@marcorusso @tharunkumarRTK @ray_aramburo @v-zhengdxu-msft 

amitchandak
Super User
Super User

@sivarajan21 , A calculated column can be dynamic. So max of CreatedOn is max in table,

 

if you want, you can create measure. Than max will based on data in avaiable because grouping of visual row filter. You can move around that using

 

calculate(Max(Table[CreatedOn]), all(Table))

 

or

 

calculate(Max(Table[CreatedOn]), allselected(Table))

 

or

calculate(Max(Table[CreatedOn]), filter(all(Table), Table[DeviceId] = Max(Table[DeviceId]) ) ) 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

 

Thanks for your quick response!

But to be frank, I didn't understand how to apply your measure concept in my case.

Can you please help?

 

Thanks in advance!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.