Forum Discussion

Polar_A's avatar
Polar_A
Icon for Helper I rankHelper I
1 year ago
Solved

DAX calculations

Hi I need help with some Dax queries.

Esentially I would like the dax to provide me a count of credit values per therapy and referring establishment, instead of it repeating for every single value.

 

The Dax code that I am using is:

CreditNoteValues =
CALCULATE(
    COUNTROWS('Cust Invoice Journal'),
    'Cust Invoice Journal'[invoiceamount] < 0,
    FILTER(
        _2_gold_prescriptions,
        _2_gold_prescriptions[clu_therapyidname] = SELECTEDVALUE(_2_gold_prescriptions[clu_therapyidname])
    ),
    FILTER(
        _2_gold_patients,
        _2_gold_patients[clu_referringestablishmentidname] = SELECTEDVALUE(_2_gold_patients[clu_referringestablishmentidname])
    )
)

 
 
KR.

PolarA
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi, Polar_A 

    Regarding the issue you raised, my solution is as follows:

    1.First I have created the following table and the column names and data are the data you have given:

    2. Below are the measure I've created for your needs:

    MEASURE =
    CALCULATE (
        SUM ( 'Table'[CreditNoteValues] ),
        FILTER (
            'Table',
            'Table'[Referring Establishment] = MAX ( 'Table'[Referring Establishment] )
                && 'Table'[Therapy] = MAX ( 'Table'[Therapy] )
        )
    )
    

    Here's my final result, which I hope meets your requirements.

     

    Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
     

    Take care to remove sensitive data.

     

    For questions about uploading data, you can try the following links:

    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

    Solved: How to upload PBI in Community - Microsoft Fabric Community

     

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Polar_A 

    Regarding the issue you raised, my solution is as follows:

    1.First I have created the following table and the column names and data are the data you have given:

    2. Below are the measure I've created for your needs:

    MEASURE =
    CALCULATE (
        SUM ( 'Table'[CreditNoteValues] ),
        FILTER (
            'Table',
            'Table'[Referring Establishment] = MAX ( 'Table'[Referring Establishment] )
                && 'Table'[Therapy] = MAX ( 'Table'[Therapy] )
        )
    )
    

    Here's my final result, which I hope meets your requirements.

     

    Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
     

    Take care to remove sensitive data.

     

    For questions about uploading data, you can try the following links:

    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

    Solved: How to upload PBI in Community - Microsoft Fabric Community

     

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.