cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Responsive Resident

## creating a measure that brings back a "count Distinct Voucher #" that will only filter in "Quarter 1

Hello,

Hoping someone could help me out with a measure Ive been trying to create.

I'm basically trying to create a new measure using the Field "Voucher Number" which will be "Count Distinct", but only bring back Quarter 1, and then Quarters 2, 3 and 4 (I think i'll be able to figure it out the other 3 once I figure out the quarter 1)

I can do this by using the Visualation "Card", by using the "Filters on the visual" ... hopefully the screen grab will help you see what I did ...

The name of the data set is "123_Charge_Data_Set" ... I'm using field "Voucher_Number" ... and a DOS - Quarter filter ...

Thanks for the help in advance 🙂

1 ACCEPTED SOLUTION
Community Support

Hi, @jonnyA

It should be caused by different data types used for comparison. You can try the following Measure.

Vouchers Qtr 1 =

CALCULATE (

DISTINCTCOUNT ( Charge_Dataset[Voucher_Number] ),

FILTER ( 'Charge_Dataset', Quarter(Charge_Dataset[DOS])= 1 )

)

Best Regards,

Caiyun Zheng

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

13 REPLIES 13
Responsive Resident

@v-cazheng-msft , if interested in solving, i having another issue related to the measure.  I cant get my total to sum correctly for Total Patients.  The total should be 4075, but Power BI is showing 4073.

Here are some of the measurse I am using ...

I tweaked the formula you gave me to count Patients.

Patients = DISTINCTCOUNT(Charge_Dataset[Patient_Name])
Here is the formula I created similar to the one you sent me ...
Patients Qtr 1 =
CALCULATE (
( Charge_Dataset[Patients] ),
FILTER ( '_Charge_Dataset', Quarter(_Charge_Dataset[DOS])= 1 ))
So I created 3 more measures similar to the one above twaeking the quarter, so the Quarter 2 measure looked like this ...
Patients Qtr 2 =
CALCULATE (
( _Charge_Dataset[Patients] ),
FILTER ( 'Charge_Dataset', Quarter(GNP_Charge_Dataset[DOS])= 2 ))
Then I did the same thing for Quarter 3 and Quarter 4
Then I created a quick measure that added Quarter 1 and Quarter 2
Then I created another measure that added Quarter 3 and Quarter 4
Finally, I crteated a measure the added the 2 abpve together which looks like this ...
Total Patients =
[Patients Qtr 1 plus Patients Qtr 2] + [Patients Qtr 3 plus Patients Qtr 4]+0
But as you can see form my screenshot the Total is off by 2.
Any chance you know why I'm off there?

Responsive Resident

@v-cazheng-msft , thank you for your time and effort with this issue.  You last solution worked, high five!

Community Support

Hi, @jonnyA

You can try a Measure like the following.

Vouchers Qtr 1 =

CALCULATE (

DISTINCTCOUNT ( Charge_Dataset[Voucher_Number] ),

FILTER ( 'Charge_Dataset', Charge_Dataset[DOS].[Quarter] = "Qtr 1" )

)

Best Regards,

Caiyun Zheng

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Responsive Resident

Your formula is very close, but when I do it on my end the formula is not liking where you have put "[Quarter]"

Thank you!

Community Support

Hi, @jonnyA

You can replace it with the QUARTER function.

Vouchers Qtr 1 =

CALCULATE (

DISTINCTCOUNT ( Charge_Dataset[Voucher_Number] ),

FILTER ( 'Charge_Dataset', Quarter(Charge_Dataset[DOS])= "Qtr 1" )

)

Best Regards,

Caiyun Zheng

Responsive Resident

@v-cazheng-msft , thank you for your time and effort with my issue.  For whatever reason, Power BI is not liking that formula.  I couldnt get it to work.

Community Support

Hi, @jonnyA

It should be caused by different data types used for comparison. You can try the following Measure.

Vouchers Qtr 1 =

CALCULATE (

DISTINCTCOUNT ( Charge_Dataset[Voucher_Number] ),

FILTER ( 'Charge_Dataset', Quarter(Charge_Dataset[DOS])= 1 )

)

Best Regards,

Caiyun Zheng

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

Sorry, but I cannot really see what is under that yellow appart from the red squiggles. Do you maybe have some extra spaces in there? I did a quick test with what I believe is a similar structure and it worked fine.

Responsive Resident

Here it is again.  I dont believe there are any unwanted spaces.  Is the "." between [DOS] and [Quarter] correct?  Im stumped?  Do you have any other ideas?

Responsive Resident

I dont know why my previous messages aren't tagging you?

Seeing if this works.

Responsive Resident

@d_gosbell , thank you for your respone, much appreciation 🙂

However, the measure is not liking something as you can see the red squigglies under [Quarter].

I circled the DOS Date Hierarchy.

Thanks in advance for the help!

Super User

If I'm understanding your requirements correctly you should be able to create a measure something like the following to create a measure that always returns the Qtr 1 value

Vouchers Qtr 1 = CALCULATE(
DISTINCTCOUNT( '123_Charge_Data_Set'[Voucher_Number] ),
'123_Charge_Data_Set'[DOS].[Quarter] = "Qtr 1"
)

Responsive Resident

@d_gosbell , thank you for your respone, much appreciation 🙂

However, the measure is not liking something as you can see the red squigglies under [Quarter].

I circled the DOS Date Hierarchy.

Thanks in advance for the help!