Convert 24 HR time - powerbi

I have a column of time data in 24 Hr time:
Time
625
844
1241
1566
Where 625 is 06:25 AM.
How can I convert this into a usable form for PowerBI? I tried the following M query in the advanced editor
Column = CONCATENATE(CONCATENATE(LEFT([Time],LEN([Time])-2),":"),RIGHT([Time],2))
but receive the following message:
Expression error: The name 'CONCATENATE' wasn't recognized. Make sure it's spelled correctly.
Thank you,

This can be done easily using DAX by creating a new column in you model and use this expression:
=FORMAT(TimeTable[time];"00:00")
You can set type and format to the column:
This will return something like this:
I hope 1566 time value is a typo in your question.
Note I am using Excel with PowerPivot but this approach can be applied to Power BI too.
Let me know if this helps.

M queries are not written like Excel or DAX formulas. Look at this site to learn more about how to write M queries.
In your case, you could add this formula in a custom column (assuming your times are in Column1):
Time.ToText(#time(Number.RoundDown([Column1] / 100), Number.Mod([Column1], 100), 0), "hh:mm tt")
If you want to keep it as a time value, then remove the Time.ToText function in the example above.

Related

Build a chart a field parameter chart with full display / topn

I have a field parameter containing 5 fields. I would like to build a chart where user can have full display (all values from field) or top10 if he wants to, ordered by CountOfItems
I try to build measure like
TOPN(10, SUMMARIZE(CategoryTable, CategoryTable[CategoryDescription], "#Count", [CountOfItems]), [#Count], DESC)
However I am getting an error that "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value." - how to overcome that? The second question is: will it apply also filters in a report to the top10 or just calculate solely top10 regardless of filters and put it into table/chart?
How to even approach such chart?
Thank you in advance
Your expression looks clean. The problem could be with your measure. Can you check/add code for [CountOfItems]? I'd try to use ADDCOLUMN + SUMMATIZE.
TOPN(
10
,ADDCOLUMNS(
SUMMARIZE(CategoryTable, CategoryTable[CategoryDescription])
,"#Count", [CountOfItems]
)
,[#Count]
,DESC
)
For the second question the answer - Yes, all filters will be applied.

Conditionally Filtering Out Rows based on 2 Parameters in w/ Power Query

I have a table similar to the one attached below:
What I would like to do, using power query, is conditionally filter out (remove) rows where CenterNum = 1101 and DepCode = 257. I figured Table.SelectRows() would work but it doesn't and the query just returns, this table is empty. The #"Expanded AccountLookup" ,in my formula below, is referencing the power query applied step before the one I am trying to create. I'm hoping to get some input on how to remove rows based on these two paramters.
= Table.SelectRows(#"Expanded AccountLookup", each [CostCenterNumber] = "1111001" and [NoteTypeCode] = "257")
Thank you!
You didn’t post a screenshot so it is hard to tell if the column format is text or numerical but try removing the quotes around the numbers
= Table.SelectRows(#"Expanded AccountLookup", each [CostCenterNumber] = 1111001 and [NoteTypeCode] = 257)
If that doesn't work, check the actual column names against what you are using, especially for case (upper/lower) and leading/trailing spaces. The best way to do that is to temporarily rename it, and look at the code for the "from name"

Why do Power Bi freezes when saving a measure?

I practiced to learn Power Bi. I have a data model of size 180931 bytes. I clicked Modelling/New Measure and the put formula Measure 2 = [Kumulatiivinen myynti €]*2. Now if I'm able to edit the formula, put the formula and try to save, the Power Bi freezes. Is there a fix for this bug?
Because this doesnt work. Normally you should get this error message:
The problem is a measure returns a single (scalar) value but your formula is row wise.
Your formula will work in the query editor (M), if you add a custom column with this expression. In the query editor you work row wise.
'M expression
= [Column1] * 2
The result will be a new column where every row has twice the value.
In a measure the correct expression would either be (for all rows):
'DAX new measure expression
= Sum([Kumulatiivinen myynti €]) * 2
or you dont add a measure (you have to add instead a new column), then you can use this expression:
'DAX new column expression
= Sumx('YourTable', 'YourTable'[Kumulatiivinen myynti €] * 2)
which is the same result as the M expression.

PowerBI/DAX: Unable to correctly compare two dates

I have this custom date that I created as a measure:
Start Date = DATE(YEAR(MAX(Loss[dte_month_end]))-1,12,31)
So this part looks fine in PowerBI and seems to be the right format.
So now I created a new column where I'm going through my data to check whether a record is equal to my "Start Date" as defined above.
IsStart = IF(Loss[dte_month_end]=[Start Date], TRUE, FALSE)
but the weird thing is that all records are evaluated to false.
I know this is actually not the case in my actual data, and I could find actual records with dte_month_end = 12/31/2017 as shown above.
Can someone help me understand why the IF statement would not be able to evaluate this correctly? I initially thought that this may be a case of the DATETIME format being inconsistent - but I purposefully changed both formats to be the same to no avail.
Thanks.
Edit1----------- FYI:
This is the format that my dte_month_end field has:
Edit2 --
I tried changing the dte_month_end format to Date instead of DateTime, and it still doesn't seem to work:
This is happening because you are using a measure inside of a calculated column. When you do this, the filter context for the measure is the row context in the table.
To fix this, you need to modify the filter context for your measure. For example:
Start Date = DATE(YEAR(CALCULATE(MAX(Loss[dte_month_end]), ALL(Loss))) - 1, 12, 31)
or
Start Date = DATE(YEAR(MAXX(ALL(Loss), Loss[dte_month_end])) - 1, 12, 31)
If you don't do this, the MAX only looks at the current row, rather than all the rows in the table.

Sharepoint calculated column based on other columns #NULL! error

I am trying to add two currency columns in a calculated column but am getting a #NULL! error.
This seems pretty straightforward but its my first time doing this in SharePoint.
SharePoint 2010 with Excel Services available.
Have create List with required columns:
Approved Value column Type = Currency
Pending Value column Type = Currency
Total Value column
Calculated (calculation based on other columns)
Type = Currency
Formula: =[Approved Value]+[Pending Value]
The values in other columns are indeed currency, but the Total shows #NULL! for all items.
I can't see anything done incorrectly.
What should I be looking for to resolve this problem?
Try using the ISBLANK function to previously check if any of the value is null.
Reference: ISBLANK function
I ended up using NZ(Value, 0)
=NZ([Approved Value],0)+NZ([Pending Value],0)
Though not sure how NULLs ended up in field or why SharePoint couldn't deal with them without this special treatment.