I drag slicer and add Month_paid field in that and convert that one to dropdown
now month looks like
Feb , aPRIL , June , Jan , Dec
i want to sort these months in dropdown how i should do this
this is the link of sample file
https://www.dropbox.com/s/sp9zfyq2sccgmmi/Claims_test_model_2.pbix?dl=0
will you please check ?
You can create a "sorting" calculated column by using the following DAX (or something similar):
Month Sort =
MONTH(Claims_excel[CLM_LOSS_DT])
Once this has been created, right click on the Claims_excel[CLM_LOSS_MONTH] and click the 'Sort by' option and choose the new column.
This will produce the following results:
If you have actual dates in your field then create a calculated column using the following logic:
YearMonthSort = YEAR(Claims_excel[CLM_LOSS_DT])*100 + MONTH(Claims_excel[CLM_LOSS_DT])
You will need another integer column in that table with numbers 1 to 12 representing the order of the Months. You can create that column in either DAX or M. When created, just select the Month column and click on 'Sort By Column' option in the Modeling tab and select the integer column which was created.This will sort the order of the months in the slicer.
If the month data in the column is already in an order starting from January to December then a simple Index column (from 'Add Column' tab in Power Query editor) is enough, else a calculated column which will check the month column value for each row and put the corresponding order number in the newly calculated integer column will be required. Refer this https://radacad.com/sort-by-column-in-power-bi
Related
I would like for a Google Sheets Query to choose which columns to select based on a cell reference. "select X" for example where the column header equals a cell that I reference. This is different from selecting which rows of a column to display. I want the Colx to be based on a cell reference.
Specifically, the data has different column headers with dates. I want the query to select the column that matches a particular date or any of the headers I may have in a drop down menu.
I used this format but it did not work
=query('Schedules'!A:N,"select A,B,C,D,E,K,H,J,L,M, '"&A2&"' WHERE N=1 and K !='HR(PD)' ORDER BY B,K",1)
This is the cell reference to the column I am looking for: '"&A2&"'
in A2 I have the letter of the column I want to use
Your current formula maybe a bit spotty with the quotes placement. You can see a working sample here:
=query(A:D,"Select A,"&F1&" Where A is not null")
based on header match
=query({A:D},"Select Col1, Col"&xmatch(F1,A1:D1)&" Where Col1 is not null")
My Datedim function is not returning yesterdays date in webi, any ideas on how to show 13/04/2022, even if it has null values?
Thanks
If you have gaps in your date data the simplest way to fill them in is to create a variable with the TimeDim() function. However, that will not work for you since you do not have a true gap because your missing date is at the end.
You need a data source with all the dates you want to display regardless of if you have data for those dates or not and then merge on your date dimension. I answered a question very similar to this here. I am copying my answer from there below...
The TimeDim() function will fill in the empty periods in your time
data. The problem with that though is if it is the end of your date
range that is missing data those dates will not show up. Let me show
you what I mean. Here is my sample data from 12/01/2021 through
12/26/2021 (note missing dates) in the table on the left. The table on
the right is the my Var Data Date TimeDim variable defined as…
=TimeDim([Data Date]; DayPeriod)
So we have our missing dates in the middle, but not at the end
(12/25/2021 and 12/26/2021). To get those dates you need a query to
return all the dates in your specified range. If you have a universe
based on a
calendar
you could use that. Free-hand SQL based on a calendar table would
suffice as well.
If you have neither of those we can still get it to work using
free-hand SQL with a CTE. This is SQL Server syntax. You will have to
modify this SQL to work for whatever database platform you have if it
isn’t SQL Server.
Here is the SQL…
;with dates ([Date]) as (
Select convert(date,‘2021-12-01’) as [Date] – Put the start date here
union all
Select dateadd(day, 1, [Date])
from dates
where [Date] < ‘2021-12-26’ – Put the end date here
)
select [Date]
from dates
option (maxrecursion 32767) – Don’t forget to use the maxrecursion option!
Source: Generate a Date Table via Common Table Expression (CTE) |
Data and Analytics with Dustin
Ryan
Here is a
demo.
Now that you have a query returning all of the dates in your range
you can merge the date from that query to your Data Date.
You can then put the date object with all of dates or the Merged Date
in table with any measures from your pre-existing query and there you
have it.
If you need to add dimensions from you pre-existing query I think you
will need to create variables for them with Qualification set to
“Detail” and the Associated dimension set to “Merged Date” (or
whatever you called it). And if you do that I believe you will also
need to check “Avoid duplicate row aggregation” check box within the
Format Table properties.
Let us know how it goes.
Hopefully that will get you on the right track.
In Power BI, I am trying to create a simple new measure column in a table that calculates using the formula below.
TestColumn =
CALCULATE(
SUM(MyTable[MyPrice]),
DATEADD(MyTable[MyDate], -12, MONTH)
)
However, in trying to display this on a table, I receive the error shown below. It appears that there is an issue with my date column.
MdxScript(Model) (28, 5) Calculation error in measure 'TestTable'[TestColumn]: A date column containing duplicate dates was specified in the call to function 'DATEADD'. This is not supported.
However, after testing it on another dataset, it appears to work, which leads me to believe that there is something wrong with the date field that I am bringing in. In the image below, the date column on the left is causing the error, whereas the column on the right works properly.
The column on the right is a date hierarchy, but the one on the left is not. Also worth noting: The data source for the column causing the error originates from an Oracle database, whereas the working one comes from SQL Server. Is there an easy fix to this error that I am receiving? Why is it that one of my date fields works with the formula, but the other does not?
Actually there are duplicate values in your table ( same date in multiple rows ). You are using time intelligence functions DATEADD which in DAX need a separate date table/dimension.
You could create a calendar table with unique and continuous dates that cover all periods of your fact table.
I have an Interactive report with floats and I want to sort the values in the correct way like:
8.00
9.00
80.00
90.00
In addition I want to show only two decimal places.
By default Apex displays this format:
How the achieve the correct formatting?
Edit:
The Data type of the column was not numeric but Varchar. After chasnging the type to number all formatting were as expected.
Lets say your IR has the following columns:
ID
Amount
Order by
Set the order by statement:
Click on the IR
Find the Source attribute on the right
Click on Order By and set the value to (choose one):
AMOUNT DESC
AMOUNT ASC
Format
The format should be set on column level on the left screen find the AMOUNT column under the IR. Now on the right you should find an attribute called Format Mask (under Appearance).
Set the value to: FM9999999.90 (choose one predefined)
SQL
Or just use an SQL query:
select ID,
TO_CHAR(AMOUNT, 'FM9999999.90') AMOUNT,
from TEST_TABLE
order by AMOUNT DESC
You can supply a format mask on the column definition.
The LOV next to the setting gives some samples
999G999G999G999G990D00
Sorting will be as expected if this table's column is numeric.
In Interactive report: Actions > Data > Sort, select column and set Ascending Direction;
In Page Designer: Choose your column and set Format Mask in Appearance section, for example: 99.99.
I am using SSRS 3.0, and SharePoint 2013. I am sorting an SSRS report on a date field. I've used expressions to plug some of the dates as alphanumeric (ie “N/A”, “Ongoing”) The customer wants the rows sorted by date with the oldest dates first and the “N/A” and the “Ongoing” dates last. The Sort function is sorting the alphas first, then the other rows that contain dates. How do I get the Sort expression to sort the dates oldest to newest and then sort the “N/A” and “Ongoing” dates last? Thank you!
You can create a computed sort expression either in the SQL or in the report. I'll give an example of doing it in the report since that's what you asked.
First, go into your group properties and then the Sorting tab. We'll add two sorting conditions. Click the "Add" button and then click the expression button.
For the first condition, we'll separate the dates and the text. So the expression would be something like this:
=IIf(IsDate(Fields!MyColumn.Value), 1, 2)
Add a second sort condition and set it to sort your column in descending order. This will put the dates first and the text after it.
Separate the result set into two parts, one for the pure date result, and the rest for 'ongoing' & 'N/A'. Combine them using UNION.
Which will be the query like this:
Select col1, col2
From table
where ... --condition to filter out those rows with real date
order by date
UNION
Select col1, case when col2 ... then 'Ongoing' when col2 ... then 'N/A'
From table
where ... --condition to filter out those rows need to be replace with characters
--not necessary using `order by for this part`
You can simply use the ORDER BY clause as follows:
SELECT MyDate FROM MyDateTable
ORDER BY
CASE WHEN MyDate IN ('n/a','Ongoing') THEN 1 ELSE 0 END,
MyDate