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
Brighton10
Helper II
Helper II

Replace blank rows with 0

Hello

I have two tables that have same columns. I have created 3 bridge tables on the country, region and sitename columns to have a one-to-many relationship. I then used the newly created country, region and sitename in my visual so i can use country in my slicer. The result in the attached pbix file (Test1BridgeTable) window is correct but i need blank values in the dieselFlowOver40l/hr to be replaced with 0. I have tried this measure but the visual is distorted whilst i just want to visualize data for filtered country.

DieselFlowOver40l/hr Count =
VAR max_Diesel_Flow_Over40 =CALCULATE(COUNTROWS(Table2),
Table2[alarmCode]="DieselFlowOver40",
FILTER(Table2,Table2[alarmStatus]="ON"),FILTER(Table2,Table2[dateTime]>=TODAY()-1)) +0
RETURN
max_Diesel_Flow_Over40
This measure is supposed to calculate the count of alarm status that were "ON" in the previous day. if there are none return 0 else return the count.
Thanks
1 ACCEPTED SOLUTION
v-yuaj-msft
Community Support
Community Support

Hi @Brighton10 ,

 

Based on your description, I modified @PhilipTreacy 's formula. Here it is as follows.

DieselFlowOver40l/hr Count = 

VAR countryname_ = SELECTEDVALUE(country[country])

VAR region_ = SELECTEDVALUE(region[region])

VAR sitename_ = SELECTEDVALUE(Table2[siteName])

VAR datetime_ = SELECTEDVALUE(Table2[dateTime])

VAR max_Diesel_Flow_Over40 =CALCULATE(COUNTROWS(Table2),

Table2[alarmCode]="DieselFlowOver40",

FILTER(Table2,Table2[alarmStatus]="ON"),FILTER(Table2,Table2[dateTime]>=DATEVALUE("2/20/2021")-1))

RETURN

IF(ISBLANK(max_Diesel_Flow_Over40)&&AND(NOT(ISBLANK([NavLightsStatus])),NOT(ISBLANK([Test_diesel_Level]))), 0 , max_Diesel_Flow_Over40)

Today is 2/23/2021, So I change the date from today() to DATEVALUE("2/20/2021").

Result:

v-yuaj-msft_0-1614050553825.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
v-yuaj-msft
Community Support
Community Support

Hi @Brighton10 ,

 

Based on your description, I modified @PhilipTreacy 's formula. Here it is as follows.

DieselFlowOver40l/hr Count = 

VAR countryname_ = SELECTEDVALUE(country[country])

VAR region_ = SELECTEDVALUE(region[region])

VAR sitename_ = SELECTEDVALUE(Table2[siteName])

VAR datetime_ = SELECTEDVALUE(Table2[dateTime])

VAR max_Diesel_Flow_Over40 =CALCULATE(COUNTROWS(Table2),

Table2[alarmCode]="DieselFlowOver40",

FILTER(Table2,Table2[alarmStatus]="ON"),FILTER(Table2,Table2[dateTime]>=DATEVALUE("2/20/2021")-1))

RETURN

IF(ISBLANK(max_Diesel_Flow_Over40)&&AND(NOT(ISBLANK([NavLightsStatus])),NOT(ISBLANK([Test_diesel_Level]))), 0 , max_Diesel_Flow_Over40)

Today is 2/23/2021, So I change the date from today() to DATEVALUE("2/20/2021").

Result:

v-yuaj-msft_0-1614050553825.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks @v-yuaj-msft This works perfectly as expected. 

PhilipTreacy
Super User
Super User

Hi @Brighton10 

The modifiction I made in the file I linked to worked fine for me so I'm not understanding why it isn't working for you.

All you need is to change the line after RETURN to

 

IF(ISBLANK(max_Diesel_Flow_Over40), 0 , max_Diesel_Flow_Over40)

 

Is this what you have done?

 

Can you please link to the actual file you are getting the blanks displayed in so I can check it?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi @PhilipTreacy Thanks for response. I have done as you said, please see screeenshots attached. Please note the 2nd window visualization is using country, region and sitename from table2. The value for dieselLevel is the same for all countries which is the incorrect value. However if you look at the first window (Test1BridgeTable), before applying the modified measure it does filter and change according to country. The country, region and sitename used on this visual are from the bridge tables. When i modify the measure those values nolonger display and the diesleflowOver40l/hr becomes zero for every country. I hope the screenshots will give a clear picture of whats happening. The desired outcome should show zeros when blank at the same returning the correct value for dieselLevel and NavlightsStatus. Thanks

https://drive.google.com/drive/folders/1Fw3XtNsQD6EM9MbReNn6NuzLY8cs6KKH?usp=sharing 

Same values when modified appliedSame values when modified appliedrelationshipsrelationshipsBefore modified measureBefore modified measuredistorted visual after modified measuredistorted visual after modified measureDesired ouputDesired ouput

PhilipTreacy
Super User
Super User

Hi @Brighton10 

Download your PBIX file with modified measure

Change the measure to this : I've added an IF after the RETURN

 

DieselFlowOver40l/hr Count = 
VAR countryname_ = SELECTEDVALUE(country[country])
VAR region_ = SELECTEDVALUE(region[region])
VAR sitename_ = SELECTEDVALUE(Table2[siteName])
VAR datetime_ = SELECTEDVALUE(Table2[dateTime])
VAR max_Diesel_Flow_Over40 =CALCULATE(COUNTROWS(Table2),
Table2[alarmCode]="DieselFlowOver40",
FILTER(Table2,Table2[alarmStatus]="ON"),FILTER(Table2,Table2[dateTime]>=TODAY()-1))
RETURN
IF(ISBLANK(max_Diesel_Flow_Over40), 0 , max_Diesel_Flow_Over40)

 

blnk1.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


HI @PhilipTreacy , the diesel level is returning the same value instead of changing. The original pbix file on testbridge table is using values from the bridge tables specifically country,   region and sitename then the other table is using vales from the table. The desired table should have filtered diesel level values and zeros as shown. Thanks desired result.PNG

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.