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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

How to convert this to measure?

Hi,
Here I have the qurey which is used to get count.
Now my taks is to create measure in Power BI for thsi below query.

select  count(*)
from factARInvoices
where Account_SK in (select Account_SK  from factARInvoices where InvoiceID='CAN005578INV' ) and
InvoiceDate <(select InvoiceDate from factARInvoices where InvoiceID='CAN005578INV' ) and GETDATE() > DueDate;


Can anyone please help me to do this.

Thanks in advance.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try like

measure =
var _account = selectcolumns(filter(factARInvoices,factARInvoices[InvoiceID]="CAN005578INV"),"Account_SK" , factARInvoices[Account_SK])
var _date = maxx(filter(factARInvoices,factARInvoices[InvoiceID]="CAN005578INV"), factARInvoices[InvoiceDate])
return
calculate(countrows(factARInvoices), filter(factARInvoices, factARInvoices[Account_SK] in _account && factARInvoices[InvoiceDate] <_date && factARInvoices[DueDate] <=today())

 

or

measure =
var _account = maxx(filter(factARInvoices,factARInvoices[InvoiceID]="CAN005578INV") , factARInvoices[Account_SK])
var _date = maxx(filter(factARInvoices,factARInvoices[InvoiceID]="CAN005578INV"), factARInvoices[InvoiceDate])
return
calculate(countrows(factARInvoices), filter(factARInvoices, factARInvoices[Account_SK] = _account && factARInvoices[InvoiceDate] <_date && factARInvoices[DueDate] <=today())

View solution in original post

@Anonymous , in place of hardcoded invoice no 

use

= selectedvalue(invoice[invoiceno])

if more than one 

in allselected(invoice[invoiceno]) 

or

in values(invoice[invoiceno])

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Try like

measure =
var _account = selectcolumns(filter(factARInvoices,factARInvoices[InvoiceID]="CAN005578INV"),"Account_SK" , factARInvoices[Account_SK])
var _date = maxx(filter(factARInvoices,factARInvoices[InvoiceID]="CAN005578INV"), factARInvoices[InvoiceDate])
return
calculate(countrows(factARInvoices), filter(factARInvoices, factARInvoices[Account_SK] in _account && factARInvoices[InvoiceDate] <_date && factARInvoices[DueDate] <=today())

 

or

measure =
var _account = maxx(filter(factARInvoices,factARInvoices[InvoiceID]="CAN005578INV") , factARInvoices[Account_SK])
var _date = maxx(filter(factARInvoices,factARInvoices[InvoiceID]="CAN005578INV"), factARInvoices[InvoiceDate])
return
calculate(countrows(factARInvoices), filter(factARInvoices, factARInvoices[Account_SK] = _account && factARInvoices[InvoiceDate] <_date && factARInvoices[DueDate] <=today())
Anonymous
Not applicable

Thanks @amitchandak.
Its works fine but i want to do another feature in this, which is the InvoiceID was choosen dynamically by slicer.
If you know any kind of work around, Can you please help me on that.

@Anonymous , in place of hardcoded invoice no 

use

= selectedvalue(invoice[invoiceno])

if more than one 

in allselected(invoice[invoiceno]) 

or

in values(invoice[invoiceno])

Anonymous
Not applicable

Thanks  once again @amitchandak , Values(invoiceno) works .

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors