I have a report to create requested by the user, now my problem is I was stuck while creating it in an RTF template. Because I have a two columns that contains different value. For example, I have a table that contains a value. Please see below.
Item_Number Discount Number1 Number2
Item1 500 145 156
Then I want in the report that when the discount is greater than 0, it will returned the column Number1 else Number2
I tried <?xdofx:if DISCOUNT < 0 then ‘Number1’ else 'Number2' end if?>
but I returned the value of the 3 columns. I tried also to removed the apostrophe but I returned the same value.
Related
I need to create a Measure to mark the row with 1 or 0 based on maximum count of a column Country. The country which has maximum count should be marked with 1 else 0. I am doing this in three steps. First finding count of all countries using SUMMARIZE function and then in second step I am finding the maximum value from the table created in the first step using SUMMARIZE function again. In the third step comparing the value of 2 step with count of each country, if they are equal then return 1 else 0.
Below is the DAX query which is giving wrong output :
CountOfState =
var t1 = SUMMARIZE(customer,customer[State Province],"CountOfStates",count(customer[State Province]))
var t2 = SUMMARIZE(t1,"countofstatess",maxx(t1,[CountOfStates]))
var v1 = CALCULATE(count(customer[State Province]),ALLEXCEPT(customer,customer[State Province]))
Return
if(v1 = t2,1,0)
--There is something wrong in var t2. t2 is giving wrong values because it is filtering out the values and I cannot figure out how to use ALL function for table expression.
Below is the wrong output :
Expected output :
As Texas has the highest count 3 this should be marked as 1 and others as 0.
Thanks in Advance.
I am new to Power BI and got stuck with the following problem:
For research purposes, I have some data about the participation of students of acourse (the example chart you can see is filtered by students not visiting the course.
The first barchart shows how many students visited those course, the second chart should show those values in percent, calculated from the subtotal.
So the value in percent of Bachelor in SS 15 should be 23,305% (total bachelor students in SS15 was 2533: 595 / 2533 * 100)
I am not able to get this values correctly calculated.
Thanks for your help!
EDIT
The Data is structured as followed:
Hash Semester Status Stg (...)
xxx1 SS 15 A Diplom
xxx2 WS 16/17 A Master
xxx1 SS 15 N Diplom
xxx1 SS 17 A Bachelor
xxx2 SS 15 N Bachelor
... ... ... ...
The hash is the identifier for the Student.
The data contains around 55.000 rows and is imported as an unstructured Excel-list. The chart is filtered by status.
Until now I dont use custom measures but the build in measures via drag and drop.
I got the percentage values by selecting "show value as percent from column total".
First, create these following 3 measures-
1.
hash_total = COUNT(your_table_name[Hash])
2.
hash_semester_total =
var cur_sem = MAX(your_table_name[Semester])
RETURN
CALCULATE(
COUNT(your_table_name[Hash]),
FILTER(
ALL(your_table_name),
your_table_name[Semester] = cur_sem
)
)
3.
hash_percentage = [hash_total]/[hash_semester_total]
Change the Type of measure "hash_percentage" as %
Now configure your clustered column chart as below-
The output will be as below-
I'm trying to find the last instance of a value in a sheet. The value is an amount of currency, and the condition should be if the type of currency is Income. For example, I have a sheet with
Date Name Amount Type
2019-08-01 Cash on hand 52.52 Income - Allowance
2019-08-02 Cash on hand 33.33 Income - Hourly
and I want to match the latest amount of income (33.33) and display it in another cell.
I've tried something like =INDEX(FILTER(A:A;NOT(ISBLANK(A:A)));ROWS(FILTER(A:A;NOT(ISBLANK(A:A)))) from Get the last non-empty cell in a column in Google Sheets where instead of NOT(ISBLANK()) I tried to put "Income*. I also tried to do a chain of MAX(FILTER()), but I got an error:
FILTER has mismatched range sizes. Expected row count: 999. column count: 1. Actual row count: 1, column count: 1.
Any help would be much appreciated.
=QUERY(A2:D, "select C where D matches 'Incom.*' offset "&COUNTA(
QUERY(A2:D, "select C where D matches 'Incom.*'", 0))-1, 0)
I am working on powerbi, using data over 2 months period, writing dax queries and trying to build reports.
I am trying to show the monthly values in cards visuals.
And i am able to do it using the measure below.
Sample Data:-
PlanPrevMon = CALCULATE([PlanSum],PREVIOUSMONTH('Month Year'[Date]))
CustomKPI = IF(ISBLANK([PlanSum]),"No Data Available ",[PlanSum])&" "&IF([PlanSum]=[PlanPrevMon],"",IF([PlanSum] > [PlanPrevMon],UNICHAR(8679),UNICHAR(8681))&IF([PlanSum]<=0,"",""))
But here i don't want user to choose the month values from slicer.
I would like to show the card values as
if current month value is not available then it should compare with the previous month value automatically as shown in an image below
For example, Apr-2017 value is not available; in this scenario I would like it to compare with the Mar-2017 value.
If Mar-2017 value also not available, then the previous month value and so on
Edit
I tried what #user5226582 suggested but still getting wrong values as below image.
As you can see i restricted to crosscheck whether the value is getting in a right way of not.
But not.
This is the measure i have used as #user5226582 suggested.
c =
var temp = 'Revenue Report'[Date]
return CALCULATE(LASTNONBLANK('Revenue Report'[Planned Rev],
'Revenue Report'[Planned Rev]),
ALL('Revenue Report'),
'Revenue Report'[Date]<=temp)`
Can you please correct me if i am doing anything wrong
Does this help...?
To get the PlanPrevMon column to show like this, I first created a new index column:
id = COUNTROWS(FILTER(Sheet1, EARLIER(Sheet1[Date],1)>Sheet1[Date]))
Then I used the index to help create the PlanPrevMon column in two steps:
Step 1: I made one column named PlanPrevMon1.
PlanPrevMon1 = SUMX(FILTER(Sheet1,Sheet1[id]=EARLIER(Sheet1[id])-1),Sheet1[PlanSum])
Step 2: I made another column named PlanPrevMon.
PlanPrevMon = if(ISBLANK(Sheet1[PlanPrevMon1]),
if(Sheet1[id]=1,0,CALCULATE(LASTNONBLANK(Sheet1[PlanPrevMon1],Sheet1[PlanPrevMon1]),ALL(Sheet1),ISBLANK(Sheet1[PlanSum]))),
Sheet1[PlanPrevMon1])
For the card, I used this measure:
Card = CALCULATE(LASTNONBLANK(Sheet1[PlanPrevMon],1),FILTER(Sheet1,Sheet1[id]=max(Sheet1[id])))
I hope this helps.
You can use LASTNONBLANK DAX function.
Example data:
a b
1 1
2
3 2
4
5 3
Calculated column:
c =
var temp = Table1[a]
return CALCULATE(LASTNONBLANK(Table1[b],Table1[b]),ALL(Table1),Table1[a]<=temp)
Results in:
a b c
1 1 1
2 1
3 2 2
4 2
5 3 3
Currently I'm trying to filter the output I have to display only products which have discounts greater than or equal to 60%. The variable discount lists all their values in the format such as 50%, 60% etc.
PROC SQL;
SELECT discount.Product_ID,Product_Name,Start_Date,End_Date,Discount
FROM Final.discount AS d, Final.product_dim AS p
WHERE d.Product_ID=p.Product_ID
AND Discount >= 60%;
QUIT;
I dont know why this isn't working, but the error from the log tells me that the percent sign isnt recognized? How would I fix this to get the output I desire?
Assuming the variable is numeric with the PERCENTw.d format applied (so likely PERCENT5. given your display), you would write it like so:
Discount >= 0.6;
The PERCENTw.d format displays numbers between 0 and 1 as 0% - 100%.
If your variable is character, then you would probably need to convert it to a number first (as '100%' > '60%' is false).
input(Discount, PERCENT5.) >= 0.6
This is well covered in Rick Wicklin's blog post on the Do Loop.