Forum Discussion

tgfauzan9303's avatar
tgfauzan9303
Regular Visitor
6 years ago

Recreate formula from JS calculation to power bi report

I need sample query on how create this JS formula into power Bi report and where to put it. Any help will do thanks.

function setDrilldownRestriction(obj){
var column = event.target.id.split(";");
if(column.length > 0){

if(column[0]=="wrhwr_eot_overdue.total_generated"){
restriction += "wrhwr_eot_overdue.status_generated = '1' AND ";
}
if(column[0]=="wrhwr_eot_overdue.total_open"){
restriction += "wrhwr_eot_overdue.status_open ='1' AND ";
}
if(column[0]=="wrhwr_eot_overdue.total_complete"){
restriction += "wrhwr_eot_overdue.status_complete='1' AND ";
}
if(column[0]=="wrhwr_eot_overdue.total_overdue"){
restriction += "wrhwr_eot_overdue.status_overdue='1' AND ";
}
if(column[0]=="wrhwr_eot_overdue.total_eot"){
restriction += "wrhwr_eot_overdue.status_eot='1' AND ";

3 Replies

  • v-lid-msft's avatar
    v-lid-msft
    Icon for Community Support rankCommunity Support

    Hi tgfauzan9303 ,

     

    We can try to create a calculated column to meet your requirement:

     

    Restriction =
    VAR CharLocal =
        FIND ( ";", [event.target.id] )
    VAR Column0 =
        LEFT ( [event.target.id], CharLocal )
    RETURN
        SWITCH (
            Column0,
            "wrhwr_eot_overdue.total_generated", "wrhwr_eot_overdue.status_generated = '1' AND ",
            "wrhwr_eot_overdue.total_open", "wrhwr_eot_overdue.status_open ='1' AND ",
            "wrhwr_eot_overdue.total_complete", "wrhwr_eot_overdue.status_complete='1' AND ",
            "wrhwr_eot_overdue.total_overdue", "wrhwr_eot_overdue.status_overdue='1' AND ",
            "wrhwr_eot_overdue.total_eot", "wrhwr_eot_overdue.status_eot='1' AND "
        )

     

    If it doesn't meet your requirement, Could you please provide a mockup sample based on fake data or describle the fields of each tables and the relations between tables simply? It will be helpful if you can show us the exact expected result based on the tables. Please upload your files to OneDrive For Business and share the link here.

     

    Please don't contain any Confidential Information or Real data in your reply.


    Best regards,

     

      • v-lid-msft's avatar
        v-lid-msft
        Icon for Community Support rankCommunity Support

        Hi tgfauzan9303 ,

         

        How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


        Best regards,